iOS10 NSLog is limited to 1024 chars strings

こ雲淡風輕ζ 提交于 2019-12-08 22:05:43

问题


In iOS10 the NSlog are limited to 1024 characters has anybody know a workaround to print complete string.


回答1:


try printf then instead of NSLog like,

   printf("%s", [string UTF8String]);

It may works




回答2:


I thinks this is a same question with [ NSLog on devices in iOS 10 / Xcode 8 seems to truncate? Why?, I will also post my answer here, in case you want to use printf instead.

This is a temporary solution,since I think it's a bug.

Just redefine all NSLOG to printf in a global header file.

#define NSLog(FORMAT, ...) printf("%s\n", [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);



回答3:


a Swift workaround for this new Xcode8 and Sierra “feature”…

func Log(_ format:String, _ args:CVarArg...) {
    let output = withVaList(args, { (p) -> NSString in
        NSString(format: format, arguments: p)
    }) as String
    print( output )
}

Of course, this won’t have the features of NSLog that we may require such as the time stamp, bundle name, and thread stuff (including serialization).



来源:https://stackoverflow.com/questions/39538320/ios10-nslog-is-limited-to-1024-chars-strings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!