Objective c 在Swift中声明全局宏

Objective c 在Swift中声明全局宏,objective-c,swift,Objective C,Swift,我想声明一个宏函数,比如目标C #define SIGNATURE_END() { if([[Config sharedInstance] checkConsoleLevel:ConsoleLogVerbose] == YES) { NSString *message = [NSString stringWithFormat:@"<< %s",__PRETTY_FUNCTION__]; Verbose(message); } } #define SIGNATURE_E

我想声明一个宏函数,比如目标C

    #define SIGNATURE_END() { if([[Config sharedInstance]    checkConsoleLevel:ConsoleLogVerbose] == YES) { NSString *message = [NSString stringWithFormat:@"<< %s",__PRETTY_FUNCTION__]; Verbose(message); } }

#define SIGNATURE_END(){if([[Config sharedInstance]checkConsoleLevel:ConsoleLogVerbose]==YES){NSString*message=[NSString stringWithFormat:@“您想要一种调试输出。它是在Swift中完成的,就像这样:

func __enter(file: String = #file, line: Int = #line, column: Int = #column, function: String = #function) {
    print("\(file):\(line):\(column) >> \(function)")
}

func __leave(file: String = #file, line: Int = #line, column: Int = #column, function: String = #function) {
    print("\(file):\(line):\(column) << \(function)")
}

func xxx() {
    __enter()
    print("xxx")
    __leave()
}

xxx()

/*
/var/folders/mz/4rdq8yg95v56bhbndfvnr7z4lwl1px/T/lldb/875/playground162.swift:13:12 >> xxx()
xxx
/var/folders/mz/4rdq8yg95v56bhbndfvnr7z4lwl1px/T/lldb/875/playground162.swift:15:12 << xxx()
*/
func#enter(文件:String=#文件,行:Int=#行,列:Int=#列,函数:String=#函数){
打印(“\(文件):\(行):\(列)>>\(函数)”)
}
函数离开(文件:字符串=#文件,行:Int=#行,列:Int=#列,函数:字符串=#函数){

打印(“\(文件):\(行):\(列)您需要一种调试输出。它在Swift中完成,如下所示:

func __enter(file: String = #file, line: Int = #line, column: Int = #column, function: String = #function) {
    print("\(file):\(line):\(column) >> \(function)")
}

func __leave(file: String = #file, line: Int = #line, column: Int = #column, function: String = #function) {
    print("\(file):\(line):\(column) << \(function)")
}

func xxx() {
    __enter()
    print("xxx")
    __leave()
}

xxx()

/*
/var/folders/mz/4rdq8yg95v56bhbndfvnr7z4lwl1px/T/lldb/875/playground162.swift:13:12 >> xxx()
xxx
/var/folders/mz/4rdq8yg95v56bhbndfvnr7z4lwl1px/T/lldb/875/playground162.swift:15:12 << xxx()
*/
func#enter(文件:String=#文件,行:Int=#行,列:Int=#列,函数:String=#函数){
打印(“\(文件):\(行):\(列)>>\(函数)”)
}
函数离开(文件:字符串=#文件,行:Int=#行,列:Int=#列,函数:字符串=#函数){

打印(“\(文件):\(行):\(列)这不是全局函数,这是用于更正的macro.oki thx,Swift中没有预处理器。这不是全局函数,这是用于更正的macro.oki thx,Swift中没有预处理器。