2015-04-06 60 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];