Difference Between release and dealloc messages????

Discussion in 'iOS Programming' started by priyank.ranka, Oct 10, 2008.

  1. priyank.ranka macrumors member

    Joined:
    Jun 11, 2008
    #1
    Hi EveryOne,
    I know its basic question that i should know but i don't know. Please help me by giving some brief comments on what exactly is the difference between the dealloc method and release method. I am developing a game in which initially when game was over i used to dealloc all the UIImageView objects and used to transfer the control to main menu and when user clicks start game button it alloc all the UIImageView objects. But during the course of game play, game gets deactivated and error splashes on debugger screen is " EXE_BAD_SIGNAL". But the issue was slove when i replaced dealloc by release message. But i don't know what is the exact difference. I went through memory management guide but still didn't get the answer. PLease help me out.
     
  2. priyank.ranka thread starter macrumors member

    Joined:
    Jun 11, 2008
  3. xsmasher macrumors regular

    xsmasher

    Joined:
    Jul 18, 2008
    #4
    Short answer:
    Each object keeps a count of how many times it has been retained. Calling "release" reduces that count by one - it does not necessarily get rid of the object, if someone else has retained it. Dealloc is the real deal - the object will be destroyed.

    You should not, as far as I know, ever call dealloc (other than [super dealloc] at the end of your own dealloc method.) It will get called by "release" if no one else is retaining the object (When the count has gone to 0.)
     

Share This Page