所以我有一个班级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.h
中的协议:
#import "CommentViewController.h"
@interface FirstViewController : UIViewController <CommentViewControllerDelegate>
植入FirstViewController
:
- (void)commentViewControllerDidFinish:(CommentViewController *)controller {
[self dismissModalViewControllerAnimated:YES];
}
此行显示错误:
@interface FirstViewController : UIViewController <CommentViewControllerDelegate>
错误:Cannot find protocol declaration for 'CommentViewControllerDelegate'; did you mean 'UISplitViewControllerDelegate'?
我错过了什么吗?我总是遇到协议和代理问题。
答案 0 :(得分:7)
您的包含文件中有一个循环。
从CommentViewController.h
#import "FirstViewController.h"
它没有在头文件中引用,如果是,你可以简单地把:
@class FirstViewController;
而不是包含整个文件。