NSString nslog revealing “\n” newline character

对着背影说爱祢 提交于 2019-12-01 15:10:59

问题


I want to log an NSString but when I log it, it doesn't show the new line character " n". How can I make it so it does? Thanks.


回答1:


You can process the string first and replace all occurrences of \n with \\n

NSString *newString = [originalString stringByReplacingOccurrencesOfString:@"\n" withString:@"\\n"];


来源:https://stackoverflow.com/questions/6052073/nsstring-nslog-revealing-n-newline-character

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