Reputation: 11
I have something like this:
I have an application that has a NSTextfield
named userName, a NSTextfield
named helloName, and a NSButton
that starts the whole process. All it does is that the user types in his/her name in the Name textfield.
when the user presses confirm, the Hello textfield will say something like "Hello, userName" whereas userName is the string that is taken directly from the Name textfield.
I know that there is a way to take the string value from the Name textfield and use %@
to add that value to the sentence "Hello, userName". But I can't find it anywhere...
Upvotes: 1
Views: 1030
Reputation: 44103
You are looking for [NSString stringWithFormat:]
NSString* helloSentence = [NSString stringWithFormat:@"Hello, %@", [userName stringValue];
Upvotes: 2