Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 764
EarlGrey Avatar asked Nov 10 '11 01:11

EarlGrey


2 Answers

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

like image 87
David Dunham Avatar answered Oct 24 '22 05:10

David Dunham


Add a \n in your string literal.

More details here

like image 23
parapura rajkumar Avatar answered Oct 24 '22 05:10

parapura rajkumar