NSString: newline escape in plist

前端 未结 5 615
终归单人心
终归单人心 2020-12-04 21:23

I\'m writing a property list to be in the resources bundle of my application. An NSString object in the plist needs to have line-breaks in it. I tried \\n

5条回答
  •  攒了一身酷
    2020-12-04 22:03

    I found a simpler solution:

    NSString *newString = [oldString stringByReplacingOccurrencesOfString:@"\\n" withString:@"\n"];
    

    It seems the string reader escapes all characters that need to be escaped such that the text from the plist is rendered verbatim. This code effectively drops the extra escape.

提交回复
热议问题