开发者

viewDidLoad, awakeFromNib, initWithCoder:...Where to init members?

Just a simple question...I'm using Interface Builder for creating my view, and I wonder where I should initialize my UIViewController's member variables (which are not IBOutlets)...viewDidLoad? awakeFromNib? initWithCoder:?

Thank开发者_StackOverflow中文版s for your answers!


Use awakeFromNib if you need to do anything extra with your IB outlets before the view is actually loaded (so at the time post when the NIB is loaded), otherwise you can normally initialise member variables in viewDidLoad:

This method is most commonly used to perform additional initialization steps on views that are loaded from nib files.

In general, if you follow how Apple's samples initialise member variables you'll be fine; you only need to consider changing the location of member initialisation if it's not appropriate to do it when the view is loaded.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜