iOS: How to know if viewDidLoad got called?

kev picture kev · Oct 18, 2013 · Viewed 9.6k times · Source

Is there a BOOL or some other way of knowing if viewDidLoad: has been called?

I need to change a view property every time my view has entered active, but if the view hasn't ever been loaded, I don't want to prematurely trigger viewDidLoad:. If there isn't way of easily telling if viewDidLoad: has been called, I'll simply add a BOOL called loaded set to NO in the view controller init, then change the view properties after entered active if loaded is YES or in viewWillAppear: if loaded is NO then set loaded to YES.

Answer

Tommy picture Tommy · Oct 18, 2013

Use isViewLoaded. Other than that it does exactly what you want, there's not that much to say about it. The documentation is as simple as:

Calling this method reports whether the view is loaded. Unlike the view property, it does not attempt to load the view if it is not already in memory.