1

I have a bit of an odd problem. I have been populating a UITextView as follows, and it has been working fine.

textView.Text = @"Blah blah blah\nblah blah blah";

Now I have moved the string to a plist and I am grabbing the text dynamically from that plist and now the '\n' is actually showing the in the text view but I want it to function as a new line. Any ideas what might be the issue?

I am using a custom method for grabbing the text from the plist like so.

+ (NSString*)readValueFromPlist:(NSString*)plistName forKey:(NSString*)key
{
    NSString *path = [[NSBundle mainBundle] pathForResource:plistName ofType:@"plist"];

    NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:path];

    return [dict valueForKey:key];
}
Jake Sankey
  • 4,977
  • 12
  • 39
  • 53

1 Answers1

2

Putting a literal \n in a plist file won't work. You have to use 'option + enter' instead when editing the text value. Or you can unescape the literal \n sequence yourself programmatically.

You can find more details here: NSString: newline escape in plist

Community
  • 1
  • 1
aroth
  • 54,026
  • 20
  • 135
  • 176