I’m getting this error,
Unknown type name ArrowWrapper
from within BoxSprite.h
#import <Foundation/Foundation.h>
#import "cocos2d.h"
#import "BoxSum.h"
#import "ArrowWrapper.h"
@interface BoxSprite : CCSprite {
}
@property ArrowWrapper* arrowItem;
@end
Also, ArrowWrapper.h contains this.
#import "cocos2d.h"
#import "BoxSprite.h"
@interface ArrowWrapper : CCMenuItem {
}
@property BoxSprite* box;
@end
The error used to be in ArrowWrapper saying it couldnt find BoxSprite until I did a clean, and now it’s in BoxSprite saying it can’t find ArrowWrapper.
I can’t figure out what I’m missing.
Thanks in advance for any help.
You have a recursive import: “BoxSprite.h” imports “ArrowWrapper.h” and vice versa.
You have to remove one of the
importstatements and use@classinstead. For example in “BoxSprite.h” replaceby
You can then import “ArrowWrapper.h” in the implementation file “BoxSprite.m”, if necessary.
Detailed explanation: Xcode displays the error in “BoxSprite.h”, but the error actually occurs when “ArrowWrapper.m” is compiled:
ArrowWrapperclass.ArrowWrapperclass has not been defined yet, causing the compiler error.Replacing
importby@classsolves the problem, because it makes theArrowWrapperclass known to the compiler at that point without reading the interface file.