2010-04-13 52 views
0
char asd='a'; 
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Are you sure?" message:asd 
       delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil]; 
[alert show]; 
[alert release]; 

上面的代碼不在iPhone模擬器中編譯。 這是爲什麼? :)iPhone SDK簡單提醒信息問題

+0

什麼錯誤信息,你得到什麼? – 2010-04-13 13:17:41

回答

0
  1. 你不編譯的iPhone 模擬器,編譯在你的Mac。
  2. 您是否收到錯誤訊息?
  3. 消息參數應該是NSString,而不是char
1

你試圖傳遞一個char其中一個NSString的預期。閱讀Objective-C和Cocoa/Cocoa Touch文檔。

爲了解決您的問題,試試這個:

NSString *asd = @"a"; 
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Are you sure?" message:asd 
       delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil]; 
[alert show]; 
[alert release];