Using a newline character with Core Data and displaying it properly in the iPhone
I'm storing a list of things in one string stored in a core data database. For example.. the stored string would look like @"apple \n pear \n orange". I'm using a UITextView to display the list and I 开发者_JAVA百科want it to display like:
- apple
- pear
- orange
..but it just displays: apple \n pear \n orange
Anyone know how to get it to honor the newline characters? I'm setting the UITextView's text just like this. list is equal to "apple \n pear \n orange"
myTextView.text = fruits.list;
this is happening because xcode takes "\n" as a literal string \n. You have to have 2 \'s because the first is an escape character that will tell xcode that your \ is not a string. It looks like:
NSString @"apple \\n pear \\n orange";
精彩评论