removeFromSuperview

Discussion in 'iPhone/iPad Programming' started by chaonic, Jul 27, 2008.

  1. macrumors newbie

    Joined:
    Feb 22, 2008
    #1
    Ok, I have a completely n00b question...

    When I'm done with a view, how do I delete it completely so that it does not continue to occupy memory?

    I'm thinking it's like this...

    Code:
    [view1 removeFromSuperview];
    [view1 release];
    
    Apple's documentation mentions that "the receiver is also released." Does that mean that you do not need to "release" the object after removing it from the superview?

    Thanks!
     
  2. Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    When a view is added to a subview, it is retained. When it is removed, it is released. You only need to release it explicitly if you retained it in the first place before adding it to the subview.
     
  3. thread starter macrumors newbie

    Joined:
    Feb 22, 2008
    #3
    Another question about releasing objects...

    Thanks kainjow. I have one more question regarding releasing objects.

    If create and place objects in an array, are they released when the array is released... or do you need to release the objects individually and then release the array?
     

Share This Page