Reputation: 271
We have error: cannot find protocol declaration for 'ClassWhichUseMainScene' [3]
We created file: Protocol.h
#import "ScoreSystem.h"
#import "OtherSystem"
#import "OtherSystem2"
@class ScoreSystem;
@protocol SceneDelegate <NSObject>
@property (nonatomic, readonly,retain) ScoreSystem* score;
@property (nonatomic, readonly,retain) OtherSystem* system;
@property (nonatomic, readonly,retain) OtherSystem2* system2;
@end
And use in ScoreSystem.h
#import "Protocol.h"
#import "OtherSystem"
#import "OtherSystem2"
@interface ScoreSystem: NSObject <SceneDelegate>
{
OtherSystem* system;
OtherSystem2* system2;
}
In ScoreSystem we want use just OtherSystem and OtherSystem2 objects. In OtherSystem use ScoreSystem and OtherSystem2, etc. We want create universal protocol for all system.
Upvotes: 1
Views: 1687
Reputation: 461
Mine Problem resolved with simple import statement
#import "ProtocolContainingFile.h"
Upvotes: 0
Reputation: 86691
You have a circular dependency between your two header files (each imports the other). Do not import ScoreSystem.h
in Protocol.h, the @class
forward declaration is enough. The same goes for your other two imports.
As a general rule I avoid including class header files in other class header files - I just use @class everywhere and import the headers in the implementation files.
Upvotes: 4