Since I recently had an import loop, I move all #import
tags (related to my own files) from the header to the corresponding .m
file. I also added @class
and @protocol
forward-declarations to calm the compiler. However, I still warn:
Cannot find the protocol definition for 'MyCustomDelegate'.
As I said, there is @protocol MyCustomDelegate
before using it in @interface
-Block. Interestingly, this warning only occurs if the corresponding delegate is declared in another file (whose header is imported into the .m
file).
I read that one solution is to declare the delegate in a separate header file and import this file directly into the header of the class that the delegate implements. Is this really the way to go? Are there any other solutions? I think that these delegates have already inflated our code enough, now I have to continue and even declare my own file for it?
A small code example to better illustrate the problem:
NewFooController.h
HomeTableViewController.h
HomeTableViewController.m
#import "HomeTableViewController.h" #import "NewFooController.h" @implementation HomeTableViewController @end
source share