The View Controller Lifecycle and Low-Memory Warnings
A view controller, like any other object, is created through alloc and init. It does not, however, create its view at that time. Instead, it waits until the view is really needed before it calls loadView. This lazy creation of the view is good: for example, if you have a tab view with a dozen view controllers, the view for any particular view controller will only be created if that particular tab is selected. You can see this behavior in the console when you build and run HypnoTime – you will only see the log message indicating that the CurrentTimeViewController’s view is loaded after you switch to the Time tab for the first time.
How does a view controller know when to load its view? When ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access