Reputation: 4486
Going to decide where to put some of the initialization code. There seems to be 2 places that we can usually choose : ...LaunchingWithOptions and viewDidLoad.
Wish to ask what are the tradeoffs in choosing between the two.
Also, are there other places that we should consider for this purpose ?
Also memory usage - if a view is being swapped out of memory during memory shortage, do we have to worry about initialization done in viewDidLoad ? (Such as could the user loose any input during the process ...)
Upvotes: 0
Views: 403
Reputation: 37729
didFinishLaunchingWithOptions
belongs to AppDelegate. Usually Objects that are needed for life long as app itself are created and initialized here. Here is Life Cycle of AppDelegate.
viewDidLoad
belongs to any ViewController, and Objects that are needed for life of the ViewController are created and initialized here. Here is Life Cycle of View Controller. Other methods to consider are
init
initWithNibName: bundle:
So it depends on the nature of the Objects.
Upvotes: 4