views:

21

answers:

1

Hi experts,

thanks for going through my question. But 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... Please help me out!!!

Thanks in advance,

Kris

+1  A: 

You are looking for [NSString stringWithFormat:]

NSString* helloSentence = [NSString stringWithFormat:@"Hello, %@", [userName stringValue];
willcodejavaforfood