Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSString nslog revealing "\n" newline character

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.

like image 297
user635064 Avatar asked May 18 '11 23:05

user635064


1 Answers

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

NSString *newString = [originalString stringByReplacingOccurrencesOfString:@"\n" withString:@"\\n"];
like image 86
jjwchoy Avatar answered Sep 28 '22 09:09

jjwchoy