PDA

View Full Version : removeFromSuperview




chaonic
Jul 27, 2008, 06:43 PM
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...


[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!



kainjow
Jul 28, 2008, 09:35 AM
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.

chaonic
Jul 30, 2008, 04:55 PM
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?