我想比较,我从两种不同的方法得到的数据:从一个实例方法的第一个,并从一个类方法的第二个。我得到一个难以理解的警告和一个错误。问题Objective-C的方法比较
这是接口:
@interface RadioStation : NSObject {
NSString *name;
double frequency;
char band;
}
+(double) maxFMFrequency;
-(void) chackFrequency;
@end
这是实现:
@implementation RadioStation
+(double) maxFMFrequency {
return 107.9;
}
-(void) chackFrequency {
switch (band) {
case 'F':
if (self.frequency > [[self RadioStation] maxFMFrequency]) // in this line i get the warning and the error massage
frequency=107.9;
break;
@end
这是警告我得到:
instance method '-RadioStation' not found (return type defaults to 'id')
当我建立并运行程序我得到错误:
Thread 1: signal SIGABRT
有谁知道我做错了吗?
谢谢!
当我写这个我只得到错误按摩 – 2012-04-08 19:09:08
@shaynagar在你发布你的“'chackFrequency'”方法的代码没有闭合大括号。如果你的实际代码是这样的,那么这将是一个问题。 – NJones 2012-04-08 19:14:59