What are the differences between didFinishLaunchin

2019-04-08 05:16发布

What is the difference between the two methods didFinishLaunchingWithOption and viewDidLoad?

The former is a method of AppDlegate.m and the latter is a method of ViewController.m, but both of them perform the same mission of loading the UIs onto the view.

1条回答
We Are One
2楼-- · 2019-04-08 05:34

The application:didFinishLaunchingWithOptions: is a UIApplicationDelegate protocol method that gets called when iOS has finished setting up an area for your App to run and is the insertion point for you, the developer, to load a view controller, etc.

The viewDidLoad method on the other hand is a method of the UIViewController class that gets called when an instance of UIViewController gets its view loaded into memory. From Apple's documentation:

Called after the controller’s view is loaded into memory.

Discussion This method is called after the view controller has loaded its view hierarchy into memory. This method is called regardless of whether the view hierarchy was loaded from a nib file or created programmatically in the loadView method. You usually override this method to perform additional initialization on views that were loaded from nib files.

查看更多
登录 后发表回答