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 protected])

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to