出现错误:找不到'ClassWhichUseMainScene‘3的协议声明
我们创建了文件: 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并在ScoreSystem.h中使用
#import "Protocol.h"
#import "OtherSystem"
#import "OtherSystem2"
@interface ScoreSystem: NSObject <SceneDelegate>
{
OtherSystem* system;
OtherSystem2* system2;
}在ScoreSystem中,我们只想使用OtherSystem和OtherSystem2对象。在OtherSystem中使用ScoreSystem和OtherSystem2等,我们希望为所有系统创建通用协议。
发布于 2012-03-27 16:26:18
您的两个头文件之间存在循环依赖关系(每个头文件都导入另一个头文件)。不要在Protocol.h中导入ScoreSystem.h,@class转发声明就足够了。您的其他两个导入也是如此。
作为一般规则,我避免在其他类的头文件中包含类头文件-我只是在任何地方使用@class,并在实现文件中导入头文件。
发布于 2013-08-28 21:41:55
使用简单的import语句解决了挖掘问题
#import "ProtocolContainingFile.h"https://stackoverflow.com/questions/9885700
复制相似问题