I’ve seen this post: NSString: newline escape in plist but I’d like to know if there’s a way to pragmatically render \n line breaks.
I’m currently using:
decisionText.text = [NSString stringWithFormat: (@"%@", [replies objectAtIndex:(arc4random() % [replies count])])];
Which randomly grabs a String from the replies array. The array was loaded from a plist like so:
replies = [[NSMutableArray alloc] initWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"AdviceList" ofType:@"plist"]];
What am I missing? The answer can’t be to manually enter line breaks. That’s not programming! (Sounds like word processing to me.)
Moshe: What are you trying to do? If you’re trying to render the text into a UILabel, you have to set the number of lines (
setNumberOfLines:,0means unlimited). Then set the text(-[UILabel setText:]) and tell the label to resize itself (-[UILabel sizeToFit]). Now the label will break the lines properly to fit within the space.Good luck.