1
我也看到過類似的問題,對於同樣的錯誤。重構代碼到Arc後,我得到接收器類型'CGPointObject'對於消息實例是前向聲明錯誤。並建議將move @class方法移至聲明的.h文件和#import .h文件,並明智地使用{。接收器類型'X'的實例消息是一個前向聲明CGPOINT,IOS
我做了所有的建議,但我仍然得到錯誤。
CCParallaxNode-Extras.h
#import "cocos2d.h"
@class CGPointObject;
@interface CCParallaxNode (Extras)
-(void) incrementOffset:(CGPoint)offset forChild:(CCNode*)node;
@end
CCParallaxNode-Extras.m類
#import "CCParallaxNode-Extras.h"
#import "CCParallaxNode.h"
@implementation CCParallaxNode(Extras)
-(void) incrementOffset:(CGPoint)offset forChild:(CCNode*)node
{
for(unsigned int i=0;i < parallaxArray_->num;i++) {
CGPointObject *point = parallaxArray_->arr[i];
if([[point child] isEqual:node]) {
[point setOffset:ccpAdd([point offset], offset)];
break;
}
}
}
@end
定義:CCParallaxNode.m
#import "CCParallaxNode.h"
#import "Support/CGPointExtension.h"
#import "Support/ccCArray.h"
@interface CGPointObject : NSObject
{
CGPoint ratio_;
CGPoint offset_;
CCNode *child_; // weak ref
}
@property (nonatomic,readwrite) CGPoint ratio;
@property (nonatomic,readwrite) CGPoint offset;
@property (nonatomic,readwrite,assign) CCNode *child;
+(id) pointWithCGPoint:(CGPoint)point offset:(CGPoint)offset;
-(id) initWithCGPoint:(CGPoint)point offset:(CGPoint)offset;
@end
@implementation CGPointObject
@synthesize ratio = ratio_;
@synthesize offset = offset_;
@synthesize child=child_;
+(id) pointWithCGPoint:(CGPoint)ratio offset:(CGPoint)offset
{
return [[[self alloc] initWithCGPoint:ratio offset:offset] autorelease];
}
-(id) initWithCGPoint:(CGPoint)ratio offset:(CGPoint)offset
{
if((self=[super init])) {
ratio_ = ratio;
offset_ = offset;
}
return self;
}
@end
如何解決上述問題?
非常感謝,行之有效。 –
這是一個正確答案的隨機downvote。 – Joe