Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/9.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
Objective c 找不到协议声明_Objective C_Delegates_Protocols - Fatal编程技术网

Objective c 找不到协议声明

Objective c 找不到协议声明,objective-c,delegates,protocols,Objective C,Delegates,Protocols,因此,我有一个类CommentViewController.h,其中 #import "FirstViewController.h" @protocol CommentViewControllerDelegate; @interface CommentViewController : UIViewController { id <CommentViewControllerDelegate> delegate; } @property (nonatomic, assign) i

因此,我有一个类
CommentViewController.h
,其中

#import "FirstViewController.h"

@protocol CommentViewControllerDelegate;

@interface CommentViewController : UIViewController {
id <CommentViewControllerDelegate> delegate;
}

 @property (nonatomic, assign) id <CommentViewControllerDelegate> delegate;

- (IBAction)submit:(id)sender;

-(IBAction)cancel:(id)sender;

 @end

@protocol CommentViewControllerDelegate
-(void)commentViewControllerDidFinish:(CommentViewController *)controller;
@end
在植入
FirstViewController
时:

 - (void)commentViewControllerDidFinish:(CommentViewController *)controller {
 [self dismissModalViewControllerAnimated:YES];
 }
错误出现在这一行:

@interface FirstViewController : UIViewController <CommentViewControllerDelegate>
@interface FirstViewController:UIViewController
错误:
找不到“CommentViewControllerDelegate”的协议声明;您的意思是“UISplitViewControllerDelegate”吗?


我错过什么了吗?我在协议和代理方面总是有问题

在include文件中有一个循环

CommentViewController.h
中删除此行:

 #import "CommentViewController.h"
 @interface FirstViewController : UIViewController <CommentViewControllerDelegate>
#import "FirstViewController.h"
它未在该头文件中引用,如果它被引用,您可以简单地说:

@class FirstViewController;

而不是包含整个文件。

在包含文件中有一个循环

CommentViewController.h
中删除此行:

 #import "CommentViewController.h"
 @interface FirstViewController : UIViewController <CommentViewControllerDelegate>
#import "FirstViewController.h"
它未在该头文件中引用,如果它被引用,您可以简单地说:

@class FirstViewController;

而不是包括整个文件。

我喜欢你在2012年回答这个问题的方式,出于某种奇怪的原因,这正是五年后我一直在寻找的解决方案!我喜欢你在2012年回答这个问题的方式,出于某种奇怪的原因,这正是五年后我一直在寻找的解决方案!