dealloc problem

Discussion in 'iOS Programming' started by thomasjt, Jul 8, 2009.

  1. thomasjt macrumors newbie

    Joined:
    Apr 16, 2009
    #1
    Hello,

    So, I suspect I need to read the memory management guide, and thankfully I have printed it out. And I shall read it in all its glory tomorrow. In the meantime though, can I ask something?

    my AppDelegate creates a single object known as Game. Game then creates two objects; Data, and View, which do what their names imply.

    In Games dealloc, it calls both [data release] and [view release]. Unfortunately, while data's dealloc method is getting called just fine, views dealloc method isn't. Moreover, if I then call [view release] a second time, I get a crash because view is already released!

    How can view already be released if it's dealloc method isn't getting called? But then when called again the dealloc method works but crashes...?

    Any help would be greatly appreciated.

    Cheers,

    Tom
     
  2. ChOas macrumors regular

    Joined:
    Nov 24, 2006
    Location:
    The Netherlands
    #2
    Hi there!

    Is it possible to show the relevant code bits (alloc/retain/release/dealloc/etc) ?

    Is this at the end of the program ? Because I seem to remember that not all deallocs are thebn guaranteed to be called.
     
  3. thomasjt thread starter macrumors newbie

    Joined:
    Apr 16, 2009
    #3
    Thanks for your offer of help ChOas but I think I've fixed it (for now).

    Can I ask a question though?

    In your dealloc method for a class you should release any class ivars, right? What about ones that are just created during a routine? Do you just need to release them at the end of the routine?

    Cheers,

    Tom
     
  4. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
    Come back when you've finished reading the Memory Management Guide and see if you still need answers to these questions.
     

Share This Page