我开始在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
}
有什么想法吗? 感谢。
答案 0 :(得分:2)
您应该使用self调用实例方法。
替换方法调用语句,如下所示
[self TurnRadius:north :west];
答案 1 :(得分:1)
你忘记了冒号。
[TurnRadius:north:west];
编辑: Mahi是正确的,您还需要从self
(当前对象)调用该方法
[self TurnRadius:north:west];