Init method
instantiate the necessary objects in the Init method (follow the lazyload idea)
Initialize the Viewcontroller itself in the Init method
Loadview Method
Viewcontroller calls this method when the view needs to be displayed and it is nil. Do not call the method directly.
If you maintain views manually, you must override this method.
If you use IB to maintain views, you must not override this method.
Loadview and IB build View
Viewdidload Method
override this method to further customize the view.
In iphone OS 3.0 and later, you should also rewrite Viewdidunload to release any indexes on the view.
The data model is called after viewdidload.
Viewdidunload Method
This method is called when the system memory is tight (note: Viewcontroller is not dealloc).
when memory is tight, didreceivememorywarning is the only way to free up unused memory before iphone OS 3.0, but OS 3.0 and later viewdidunload methods are a better way.
in this method, all Iboutlet (both property and instance variables) are set to nil (the System release view has already been removed).
in this method, other view-related objects are freed, other objects created at run time (but not system-required), objects created in viewdidload, cached data, and so on.
after the release object, set the object to nil (Iboutlet only need to set it to nil, and the system release view has already been removed).
It is generally assumed that viewdidunload is a viewdidload mirror, because Viewdidload is also re-executed when view is re-requested.
the objects that are viewdidunload in the release must be objects that are easily recreated (such as objects created in Viewdidload or other methods), and do not release user data or other objects that are difficult to re-create.
Dealloc Method
Viewdidunload and Dealloc methods are not associated, dealloc still do what it has to do.
So the process should look like this:
(loadview/nib file) to load view into memory-->viewdidload function to further initialize these view--> when memory is low, call the Viewdidunload function to release views
-When you need to use view, go back to the first step
The relationship of iOS init, Loadview, Viewdidload, Viewdidunload