如何在 swift 3.0 中编写这段代码?
NSSTring *countString=[NSString stringWithFormat:@"%d %@",count,EDIT_CHAR];
其中,EDIT_CHAR 是一个宏,计数是整数。
最佳答案
Swift 没有预处理器,但您可以创建一个包含所有常量或标志的结构。
struct MyAppConstants {
static let editChar = "f"
// Etc...
}
您可以将其称为 MyAppConstants.editChar
你的问题被标记为 swift 但你发布的代码是 ObjC。
关于ios - 如何在swift 3.0中编写这段代码,特别是如何在swift3中使用宏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42065631/