您的位置:首页 > 移动开发 > Swift

swift中的print

2016-12-08 00:00 218 查看
摘要: 自定义打印

一、自定义print

1.当前路径(String):let filePath = #file

2.当前函数(String):let funcName = #function

3.当前行号(Int):let lineNum = #line

4.当前列号(Int):let columnNum = #column

5.xf_print():

func xf_print<T>(message : T, file : String = #file, funcName : String = #function, line : Int = #line, column : Int = #column) {

let file = (file as NSString).lastPathComponent

print("\(file) : [\(funcName)] (\(line)行\(column)列) - \(message)")

}

此处应作为全局函数,供外界使用。

二、去掉Xcode中多余的打印

1.Product->Scheme->Edit Scheme(或者Command + shift + <);

2.Run->Arguments->Environment Variable;

3.点击“+”,Name栏输入OS_ACTIVITY_MODE,Value栏输入disable

注:以上仅为自己学习随笔,如有错误欢迎指正!转载请注明出处,谢谢!。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Swift print