Reputation: 27
I have some strings stored in a plist dictionary, the values of which i would like to display in a textview. the strings are stored with \n for new lines, however when i pull out the string, it shows \n characters as literals instead of converting them to new lines
Here is the code to pull out the value
self.directions.text = [NSString stringWithFormat:@"%@",[self.exerciseDetail objectForKey:DIRECTIONS_KEY]];
How can i fix it?
Stored strings: some text \n some more text \n some more text
Upvotes: 0
Views: 1049
Reputation: 6420
The problem here is that the plist file is storing the string with "\" and "n" characters, rather than a single newline character. The best fix (in my opinion) would be to fix the plist file to have the correct characters. If you are using the plist editor built into Xcode, then hitting the Enter key moves you to the next field. To get around this, hold the Option key while typing Enter and a newline will be inserted.
Upvotes: 2