Reputation: 7310
So I have one class CommentViewController.h
in which I have
#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
I synthesized delegate in the implementation
I try to access the protocol in FirstViewController.h
:
#import "CommentViewController.h"
@interface FirstViewController : UIViewController <CommentViewControllerDelegate>
And in the implantation of FirstViewController
:
- (void)commentViewControllerDidFinish:(CommentViewController *)controller {
[self dismissModalViewControllerAnimated:YES];
}
The error appears on this line:
@interface FirstViewController : UIViewController <CommentViewControllerDelegate>
Error: Cannot find protocol declaration for 'CommentViewControllerDelegate'; did you mean 'UISplitViewControllerDelegate'?
Am I missing something? I always have trouble with protocols and delegates.
Upvotes: 1
Views: 1064
Reputation: 122381
You have a loop in your include files.
Remove this line from CommentViewController.h
:
#import "FirstViewController.h"
It's not referenced in that header file, and if it were, you could simply put:
@class FirstViewController;
instead of including the whole file.
Upvotes: 7