What is the difference between viewDidLoad and awakeFromNib?

Asked

Viewed 364 times

4

What is the main difference between viewDidLoad and awakeFromNib in development on Swift for iOS?

1 answer

8


awakeFromNib is a method of NSObject and is called so that the object is created from an Interface Builder file (e.g. xib)

viewDidLoad is a method of UIViewcontroller called after the Viewcontroller view is created

In other words awakeFromNib is called on any object defined in the Builder interface (subclasses of Uitableviewcell, Uiview, Uiviewcontroller, etc). Already viewDidLoad is invoked only in subclasses of UIViewcontroller, regardless of how the view was built. That is, even if the view is built programmatically, using loadView, the method is called.

In short, viewDidLoad is normally used for Viewcontrollers startup and awakeFromNib is used for other classes created with the Interface Builder as Tableviewcells

Browser other questions tagged

You are not signed in. Login or sign up in order to post.