我已经子类CCSprite和我的课,名为汽车,inits这样的:Cocos2D iPhone - 对象发送过多次autorelease?
+(Cars *) carWithNumber:(int)number COLOR:(int)color SHAPE:(int)shape {
return [[[Cars alloc] initWithNumber:number COLOR:color SHAPE:shape] autorelease];
}
-(id) initWithNumber:(int)number COLOR:(int)color SHAPE:(int)shape {
self = [self init];
if (self) {
self.texture = [self createTextureWithNumber:number COLOR:color SHAPE:shape];
}
return self;
}
然后我创建了一个汽车使用,例如,像这样:
Cars *oneCar = [Cars carWithNumber:2 COLOR:3 SHAPE:5];
[self addChild:oneCar];
看起来完美,但如果我分析和Xcode的代码,它指向该行
return [[[Cars alloc] initWithNumber:number COLOR:color SHAPE:shape] autorelease];
说对象发送-autorelease过很多次 ?????????
我错过了什么?谢谢。
该代码对我来说看起来很好。你能把它减少到一个测试用例并把它放到网上吗? – Jim 2012-03-07 14:29:59