NSString nslog revealing “\n” newline character

后端 未结 1 1902
鱼传尺愫
鱼传尺愫 2021-01-18 00:54

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条回答
  • 2021-01-18 01:37

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

    NSString *newString = [originalString stringByReplacingOccurrencesOfString:@"\n" withString:@"\\n"];
    
    0 讨论(0)
提交回复
热议问题