Swift4 学习笔记-宏定义

创建一个. swift 文件

//封装的日志输出功能(T表示不指定日志信息参数类型)
func XNSLog(_ message:T, file:String = #file, function:String = #function,
              line:Int = #line) {
    #if DEBUG
        //获取文件名
        let fileName = (file as NSString).lastPathComponent
        //当前时间
        let formatter = DateFormatter()
        //日期样式
        formatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
        let nowTime = formatter.string(from: Date())
        //打印日志内容
        print("[\(nowTime) : \(fileName) : \(line)]  \(message)")
    #endif
}

func XParserPlist(_ name:T) -> Any {
    let path = Bundle.main.path(forResource: "BillSourcePlist", ofType: "plist")
    let dic = NSDictionary(contentsOfFile: path!)!
    return dic[name]!
}


// 屏幕的bounds
let kScreen = UIScreen.main.bounds
// 屏幕的宽
let kScreenW = UIScreen.main.bounds.size.width

// 屏幕的高
let kScreenH = UIScreen.main.bounds.size.height

你可能感兴趣的:(Swift4 学习笔记-宏定义)