Wednesday, May 25, 2011

ViewDidUnload is Not Being Called

ViewDidUnload gets called after the view is nil.  This method gets called when memory is low.  If you try to release an Ad object like Mobfox or AdMob in this method instead of the dealloc method, the objects may not get released and you may receive a EXEC_BAD_ACCESS error after you leave the page.  This is because the Ad is still trying to show on the view which has been deallocated already.
If your view controller stores references to views and other custom objects, it is also responsible for relinquishing ownership of those objects safely in its dealloc method. If you implement this method but are building your application for iOS 2.x, your dealloc method should release each object but should also set the reference to that object to nil before calling super.
 http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/Reference/Reference.html

No comments:

Post a Comment