Reputation: 12373
I'm having a really basic problem with NSString stringWithFormat. I want to take the name that the user enters and display in an alertView: Welcome username.
NSString *welcomeMessage = [NSString stringWithFormat:(@"Welcome %@", passedData)];
UIAlertView *alert = [[UIAlertView alloc] //show alert box with option to play or exit
initWithTitle: welcomeMessage
message:@"Once you press \"Play\" the timer will start. Good luck!"
delegate:self
cancelButtonTitle:@"I want out!"
otherButtonTitles:@"Play",nil];
[alert show];
passedData is the username that has been entered. The way I have it at the moment - only the username is being displayed in the title of the alert box, and not the "Welcome" part. I know i'm missing some really basic knowledge here but would appreciate some help.
Upvotes: 0
Views: 147
Reputation: 7450
I think that ()
are not needed. Try using that:
NSString *welcomeMessage = [NSString stringWithFormat:@"Welcome %@", passedData];
instead of
NSString *welcomeMessage = [NSString stringWithFormat:(@"Welcome %@", passedData)];
Hope it helps
Upvotes: 3