我想比較,我從兩種不同的方法得到的數據:從一個實例方法的第一個,並從一個類方法的第二個。我得到一個難以理解的警告和一個錯誤。問題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