I’ve searched but I did not get with the solution. I have a class which inherits from NSObject. It has the following imports:
#import <Foundation/Foundation.h>
#import "Constants.h"
#import "CommonProtocols.h"
#import "SomeClass.h"
@interface SomeComtroller : NSObject
Than I have SomeClass.
#import "SomeController.h"
@interface SomeClass : NSObject
{
SomeController *myController; // ERROR!
}
@end
However, I can’t define SomeController in SomeClass. It gives me the error, I really want to have a property of SomeController in SomeClass, and have in the controller a property of someClass.
You have a circular dependency — SomeClass.h imports SomeController.h, which imports SomeClass.h, which imports…
The solution is to move the imports into the implementation files, and just forward-declare the other classes you’re using with the
@classdirective (e.g.@class SomeController;in SomeClass.h).