Question about RETAIN and Cocos2D.

Posts: 249
Joined: 2008.10
Post: #1
Hi mates!

In this code I found here:
There is one thing I don't understand. Retain count becomes 2, and the release is called, so reference counter is 1. So, isn't it a mistake (or memory leak)?

Thanks a lot.

// prevent flicker
Sprite *sprite = [[Sprite spriteWithFile:@"Default.png"] retain];
sprite.anchorPoint = CGPointZero;
[sprite draw];
// here sprite retainCount is 2, as expected
[[[Director sharedDirector] openGLView] swapBuffers];
[sprite release];

// Run the intro Scene
[[Director sharedDirector] runWithScene: introScene];
Quote this message in a reply
Posts: 5,144
Joined: 2002.04
Post: #2
spriteWithFile: returns an autoreleased object.
Quote this message in a reply
Post Reply