2014-02-09 36 views
0
-(IBAction)buttonPressed { 
    count++; 

    scoreLabel.text = [NSString stringWithFormat:@"Score\n%i", count]; 
} 

關閉初學者ios教程。他沒有得到一個錯誤。我收到錯誤-(IBAction)buttonPressed後說我需要把一個;,但它沒有;,當我把;沒有做任何事情!Xcode 5預期標識符錯誤不會消失

+0

什麼是確切的錯誤信息? –

+0

請顯示錯誤訊息 – nvl

+0

我已更新我的答案 – markhunte

回答

2

UPDATE

此完全相同的問題進行回答here error-in-obj-c-expected-identifier-or

有可能你正在做的事情的,這是錯誤的通過將IBAction爲代碼在@interface

enter image description here

而不是@implementation。

enter image description here


原來的答案

這是最有可能的前

-(IBAction)buttonPressed { 
    count++; 

    scoreLabel.text = [NSString stringWithFormat:@"Score\n%i", count]; 
} 

會做,這是一個例子你得到,因爲在代碼中的錯誤的這如果你在代碼中丟失了一個右括號「}」,只是繼續它。

實施例:

enter image description here

添加右括號 「}」 回糾正該錯誤。

enter image description here

該錯誤是在IBAction爲被引導。但是它之前的代碼是不正確的。

你可能是一個類似的代碼問題,其他地方是實際的問題。

0

嘿,如果你用筆尖使得該按鈕操作方法如果您創建此按鈕的操作方法programmically不是改變它的返回類型

- (void)buttonpressed 

希望這將工作

比糾正你的方法

- (IBAction)buttonpressed:(id)sender