开发者

Is my class going to lose its memory

I have a class with two methods listed below. I call them from another class in a function. In this function I new up my class then call fireTorpedoContinued. In C# everything would be great, but I started to think about it. I'm not retaining the class anywhere and there seems to be nothing to stop it from going out of memory between fire torpedo and firetorpedo continued. Does anything hold onto this class or do I need to retain it? For example does the execute function class retain the class? What if that was not there would I be in trouble?

- (void) fireTorpedoContinued
{
    [self.torpedoData.explosionSprite stopAllActions];
    CCPlace *placeAction = [CCPlace actionWithPosition:_endPoint];
    CCShow *showAction = [CCShow action];
    CCCallFunc *callFunctionDeathCheck = [CCCallFunc actionWithTarget:self.deathCheckSelectorTarget selector:self.deathCheckSelector];
    CCFadeOut *fadeOutAction = [CCFadeOut actionWithDuration:1.0f];
    CCCallFunc *callfunctionAction = [CCCallFunc actionWithTarget:self.completedSelectorTarget selector:self.completedSelector];

    CCSequence *sequenceAction = [CCSequence actions:placeAction, showAction, callFunctionDeathCheck, fadeOutAction, callfunctionAction, nil];
    [self.torpedoData.explosionSprite runAction:sequenceAction];

}

- (void) fireTorpedo
{
    [self.torpedoDat开发者_如何学Pythona.torpedoSprite stopAllActions];
    CCPlace *placeAction = [CCPlace actionWithPosition:_startPoint];
    CCShow *showAction = [CCShow action];
    CCMoveTo *moving = [CCMoveTo actionWithDuration:2.0f position:_endPoint];
    CCHide *hideAction = [CCHide action];    
    CCAction *callCompletedFunction = [CCCallFunc actionWithTarget:self selector:@selector(fireTorpedoContinued)];

    CCSequence *sequenceAction = [CCSequence actions:placeAction, showAction, moving, hideAction, callCompletedFunction, nil];
    [self.torpedoData.torpedoSprite runAction: sequenceAction];
}


Your question is a little fuzzy, but everything you need to know is explained here:

http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmObjectOwnership.html#//apple_ref/doc/uid/20000043-BEHDEDDB

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜