我正在使用 cocos2d 编写代码。我想释放我分配的所有内存。我已经通过以下方式在 dealloc 方法中完成了它。
我发布的所有对象都在接口文件中声明,属性(分配)已设置并在实现文件中合成。
我使用 alloc 方法来创建它们
self.PlayerA = [[CCSprite alloc] initWithFile:@" PlayerImage_01.png"];
-(void)dealloc
{
int count , i ;
count = [self.PlayerA retainCount];
for(i = 0; i < count; i++)
[self.PlayerA release];
count = [self.targetLayer retainCount];
for(i = 0; i < count; i++)
[self.targetLayer release];
count = [self.playerGunSlowDrawSheet retainCount];
for(i = 0; i < count; i++)
[self.playerGunSlowDrawSheet release];
count = [self.playerGunSlowDrawAnimation retainCount];
for(i = 0; i < count; i++)
[self.playerGunSlowDrawAnimation release];
count = [self.numberFinishedTime retainCount];
for(i = 0; i < count; i++)
[self.numberFinishedTime release];
count = [self.backGroundImage retainCount];
for(i = 0; i < count; i++)
[self.backGroundImage release];
[[CCTextureCache sharedTextureCache] removeAllTextures];
[[CCSpriteFrameCache sharedSpriteFrameCache] removeSpriteFrames];
[super dealloc];
}
但我得到:程序接收信号:“EXC_BAD_ACCESS”。我调试它在 [super dealloc] 处显示错误;
我在内存管理方面完全错了吗?或者我错过了什么。谢谢你。