Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does UIView's removeFromSuperView method remove the UIView from memory

Does UIView's removeFromSuperView method remove the UIView from memory? I just want to be sure that the view is no longer using any memory?

like image 959
TheLearner Avatar asked Jan 14 '11 11:01

TheLearner


1 Answers

UIView retains its subviews, so when you call -removeFromSuperview method then your view object is released.

So if everything else is ok with your memory management and your view is not retained by anything else then yes - your view should be deallocated and removed from memory.

Possible example when simply removing view from superview may not be sufficient to deallocate it can be view that has outlet connection and declared property for it with retain attribute - in that case it is retained by controller when it is being loaded from nib file and you may need to release that view for that case:

[iVarView removeFromSuperview];
self.iVarView = nil;
like image 168
Vladimir Avatar answered Sep 30 '22 06:09

Vladimir