> I'm interested in what to do without ViewDidUnload too.
>
> Is there some other notification we should use to free up resources,
> unsubscribe from events, etc?
>
> E.g does Dispose get called when a viewpoint roller gets popped off
> the navigation stack? (Or when the memory warning arrives like
> viewdidunload used to?)
At WWDC Apple engineers explained that the memory savings from releasing
views in ViewDidUnload was trivial. Most of the memory savings comes from
allowing the backing layers for those views to leave memory, and they
already do that regardless of whether you release the views themselves.
Since incorrect implementations of ViewDidUnload was a very common source
of crashes they decided it no longer made sense to implement those methods
at all. You're not gaining anything, and you're likely to mess it up and
crash anyway. So they decided to just deprecate the whole function. In iOS
6 it won't be called at all, and they even recommended that you just stop
implementing it in earlier OSes as well (the same logic applies).
So what do you do with the code in that function? If all you're doing is
releasing views (like ReleaseDesignerOutlets()) then just delete the code.
It's not necessary. If you were doing something else that is important for
memory savings (like releasing some caches) then move that code into
ViewDidReceiveMemoryWarning and add this condition around it:
if (IsViewLoaded && View.Window != null)
{
// Clear unnecessary caches
}
Then of course you need to have the necessary logic implemented elsewhere
to repopulate those caches whenever needed.
If you were unsubscribing from notifications then there are several
functions that you could choose from:
ViewWill/DidDisappear
Will/DidMoveToParentViewController
ViewWillDisappear is probably your best option.
You should of course ALSO include such code in the Dispose(bool) method
(with and "if (disposing)" guard).
--
Adam Kemp
[email protected]
(512) 683-6058
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch