2012-04-02 32 views
0

NSString stringWithFormatには本当に基本的な問題があります。ユーザーが入力し、alertView:Welcome usernameに表示する名前を使用したいと思います。stringWithFormatでエラーを見つけることができません

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は、入力されたユーザー名です。私は現時点でそれを持っている方法 - ユーザー名だけが警告ボックスのタイトルに表示され、「ようこそ」の部分では表示されません。私はここで本当に基本的な知識が欠けていると知っていますが、助けていただければ幸いです。

答えて

3

()は必要ありません。それを使用してみてください:代わりに

NSString *welcomeMessage = [NSString stringWithFormat:(@"Welcome %@", passedData)]; 

NSString *welcomeMessage = [NSString stringWithFormat:@"Welcome %@", passedData]; 

は、それはあなたに感謝し、それはそれと同じくらい簡単だった

+0

お役に立てば幸いです。 – garethdn

+0

@garethdnよろしいですか;) – Novarg

関連する問題