Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone Objective-C类别的问题_Iphone_Objective C_Categories - Fatal编程技术网

Iphone Objective-C类别的问题

Iphone Objective-C类别的问题,iphone,objective-c,categories,Iphone,Objective C,Categories,下面的代码给了我一个错误“找不到'StartTimerViewController'的接口声明” #import "StartTimerViewController.h" @interface StartTimerViewController (timerMethods) -(void)startTimer:(id)sender withTimeIntervalInSeconds:(NSTimeInterval)time andMessage:(NSString *)me

下面的代码给了我一个错误“找不到'StartTimerViewController'的接口声明”

#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 {
#导入
#导入“StartTimeViewController+timerMethods.h”
@接口StartTimerViewController:UIViewController{

您有一个循环引用。您不能将timermethods.h包含在StartTimerViewController.h中,因为timermethods.h需要StartTimerViewController.h。您永远不应该需要父对象知道类别,只有类别需要知道父对象


祝您好运!

您正在声明类之前导入该类别的标题。它永远不会有机会看到该类,因为它位于第一位!因此请移动
#import“StartTimeViewController+timerMethods.h“
到文件的结尾。

您的
StartTimerViewController.h
是什么样子的?尝试一个干净的构建,看看Xcode这次是否找到了您的类。报告错误的文件/行是在哪一行?是否真的为
@接口StartTimerViewController(timerMethods)报告了错误
line?StartTimerViewController是否与此在同一项目中,并作为文件包含在为此目标生成的捆绑包中?否,它是针对-(void)startTimer:(id)发送程序的时间间隔秒:(NSTimeInterval)时间报告的是,StartTimerViewController与此在同一项目中