2011-02-11 35 views
2

下面的代碼是給我的「錯誤無法找到接口聲明‘StartTimerViewController’問題Objective-C的分類

#import "StartTimerViewController.h" 

@interface StartTimerViewController (timerMethods) 

-(void)startTimer:(id)sender withTimeIntervalInSeconds:(NSTimeInterval)time 
     andMessage:(NSString *)message 
notificationChoice:(BOOL)notificationChoice 
     andWithLabel:(UILabel *)theLabel; 

-(void)updateLabel:(NSTimer *)timer; 

@end 

爲什麼會發生這種情況?StartTimerViewController.h確實存在,是一個有效的I類編碼。這個文件,應該是延長StartTimerViewController類別。

這裏的StartTimerViewController.h年初

#import <UIKit/UIKit.h> 
#import "StartTimerViewController+timerMethods.h" 

@interface StartTimerViewController : UIViewController { 
+1

你的`StartTimerViewController.h`看起來像什麼?嘗試一個乾淨的和構建,看看Xcode這次找到你的班。 – BoltClock 2011-02-11 15:41:36

回答

7

你有交流非常規的參考。您不能在StartTimerViewController.h中包含timermethods.h,因爲timerMethods.h需要StartTimerViewController.h。您絕不應該需要父母才能瞭解該類別,只有該類別需要了解該父類。

祝你好運!

0

在聲明類之前,您正在導入類別的標頭。它從來沒有機會看到這個班,因爲它是第一個!所以移動#import "StartTimerViewController+timerMethods.h"到文件的結束