difference between awakeFromNib() and viewDidLoad() in swift

妖精的绣舞 提交于 2019-11-29 04:59:54

问题


I want to know the key difference between awakeFromNib() and viewDidLoad() to get more clarity on how it works . Please can anybody explain?


回答1:


From Apple documentation:

awakeFromNib:

The nib-loading infrastructure sends an awakeFromNib message to each object recreated from a nib archive, but only after all the objects in the archive have been loaded and initialized. When an object receives an awakeFromNib message, it is guaranteed to have all its outlet and action connections already established.

See: Nib Files in Resource Programming Guide

viewDidLoad:

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.



来源:https://stackoverflow.com/questions/31993079/difference-between-awakefromnib-and-viewdidload-in-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!