Object sent autorelease too many times?

Forums Programming Programming – Everything else Object sent autorelease too many times?

This topic contains 2 replies, has 3 voices, and was last updated by  BigRed 1 year, 3 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
Author Posts
Author Posts
March 7, 2012 at 12:46 pm #239753

lunarmoon
Participant
@lunarmoon

I have subclassed CCSprite and my class, named Cars, inits like this:

+(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;
}

then I create a car using, for example, something like this:

Cars *oneCar = [Cars carWithNumber:2 COLOR:3 SHAPE:5];

It appears perfect, but if I analyze the code with Xcode, it points to this line

return [[[Cars alloc] initWithNumber:number COLOR:color SHAPE:shape] autorelease];

saying object sent -autorelease too many times ?????????

what am I missing? Thanks.

March 7, 2012 at 6:00 pm #367876

rickms
Participant
@rickms

Is your ‘init’ autoreleasing by any chance?

January 10, 2013 at 2:29 pm #367877

BigRed
Participant
@bigred

hey did you ever find a solution to this ?

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.