Xcode warns about missing protocol definition, even though @protocol is used
Xcode warns about missing protocol definition, even though @protocol is used
- Subject: Xcode warns about missing protocol definition, even though @protocol is used
- From: Florian Pilz <email@hidden>
- Date: Sat, 14 Apr 2012 14:55:29 +0200
Since I had a import-cycle recently, I'm moving all #import statements (concerning my own files) from the header into the corresponding .m-file. I also added @class and @protocol forward-declarations to soothe the compiler. However, I still get he following warning:
Cannot find the protocol definition for 'MyCustomDelegate'.
As I said, there is an @protocol MyCustomDelegate before I use it in the @interface-Block. Interestingly this warning only occurs if the corresponding delegate is declared in another file (whose header is imported in the .m-file).
I read that one solution is to declare the delegate in a separate header file and import that file directly in the header of the class that implements the delegate. Is this really the way to go? Are there any other solutions? I think those delegates already bloated our code enough, now I should go on and even declare an own file for it?
Small sample code to better illustrate the problem:
NewFooController.h:
#import <UIKit/UIKit.h>
@protocol NewFooControllerDelegate;
@interface NewFooController : UITableViewController
@property (nonatomic, weak) id<NewFooControllerDelegate> delegate;
@end
@protocol NewFooControllerDelegate
@end
HomeTableViewController.h:
#import <UIKit/UIKit.h>
// warning points to line below
@interface HomeTableViewController : UITableViewController <NewFooControllerDelegate>
@end
HomeTableViewController.m:
#import "HomeTableViewController.h"
#import "NewFooController.h"
@implementation HomeTableViewController
@end
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden