2015-04-06 32 views
1

我開始在objective-c中編程。 我收到編譯器錯誤Use of undeclared identifier when calling method調用方法時使用未聲明的標識符

頭文件

//ViewController.h 
typedef enum direction {north, south, west, east} Direction; 
- (int)TurnRadius:(Direction) currentDirection:(Direction)intendedDirection; 

實現文件:

//ViewController.m 
#import "ViewController.h" 
@implementation ViewController 
- (int)TurnRadius:(Direction) currentDirection : (Direction) intendedDirection { 
    //Irrelevant implementation details 
} 

- (IBAction)buttonTapped:(UIButton *)sender { 

    [TurnRadius north west]; //ERROR IS HERE 
} 

任何想法? 謝謝。

回答

2

你應該使用自己的呼叫實例方法。

更換你的方法調用語句如下

[self TurnRadius:north :west]; 
+0

謝謝!這工作。 – s123

1

你忘記了冒號。

[TurnRadius:north:west]; 

編輯:馬希是正確的,你還需要從self(當前對象)調用方法

[self TurnRadius:north:west];