Search code examples
objective-ciosios5uialertview

Adding line breaks in iOS alert messages using Objective-C


A noob question.

I have an alert:

"alertMessage" = "This is my message:    1  2  3.  And another one: 5 6 7";

which I am displaying with:

NSString *asd = NSLocalizedString (@"alertMessage", @"");
NSString *alertTitle = NSLocalizedString (@"alertTitle", @"");

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:alertTitle message:asd delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];

How do I implement line breaks so "And Another one:" starts on the second line.

thank you!


Solution

  • Add line break characters (\n) to your message.