having a look at the following code:
CCSprite* testsprite = [CCSprite spriteWithFile:@"test.png"];
CCLOG(@"1. count: %d", [testsprite retainCount]);
[self addChild:testsprite];
CCLOG(@"2. count: %d", [testsprite retainCount]);
[testsprite runAction: [CCMoveTo actionWithDuration:3.0 position:CGPointMake(200.0, 200.0)]];
CCLOG(@"3. count: %d", [testsprite retainCount]);
the output of this code is:
1. count: 1
2. count: 2
3. count: 3
I think I understand what happens here. The question is the following: is there a rule of thumb when (in which methods) Cocos2D retains objects (in this case testsprite)?
Bye, Christian
autoreleased:
manual memory management
Dont let the retainCount confuse you. Each line of code will maybe retain the object. If it is done well, the underlying code will release it automatically after it is finished.
A common example when you have to type release.