objective c - Why am I getting this error? CCSprite copyWithZone unrecognized selector sent to instance -
i'm having tough time figuring out why i'm running error:
ccsprite copywithzone unrecognized selector sent instance
i keep reference rectanglesprite in rectangle object. synthesize in rectangle.m file. doing incorrectly way i'm trying store rectanglesprite in rectangle's rectanglesprite property?
rectangle.h
#import "ccnode.h" #import "cocos2d.h" #import "ccsprite.h" @interface rectangle : ccnode { ccsprite *rectanglesprite; } @property(nonatomic,readwrite,copy) ccsprite *rectanglesprite; @end
cocosscene.m
... ccsprite *rectanglesprite = [ccsprite spritewithfile:@"rectangle.png"]; rectangle *rectangle = [[rectangle alloc] init]; rectangle.rectanglesprite = rectanglesprite; ...
you have defined rectanglesprite
property copy
. means ccsprite
class must conform nscopying
protocol (which means must implement copywithzone:
method).
the error indicates ccsprite
not implement copywithzone:
.
if wish retain value, rid of copy
in property declaration. use strong
(or retain
using mrc) instead of copy
.
you use copy
when want create copy of object when assigning property. requires class support copying.
Comments
Post a Comment