Swift在DEBUG模式下并沒有這個宏失晴,需要自己手動配置:
Build Settings --> Other Swift Flags --> 在DEBUG模式下配置 -D DEBUG
// 默認參數(shù),如果調用的人不傳遞使用默認參數(shù)
// 打印出來的語句:文件名+行數(shù)+方法名+你想輸出的東西本昏,好用仔戈!
func CZPrint(file: String = __FILE__, line: Int = __LINE__, function: String = __FUNCTION__, items: Any) {
#if DEBUG
print("文件: \((file as NSString).lastPathComponent), 行數(shù): \(line), 函數(shù): \(function): => \(items) \n")
#endif
}