iPhone dev - create array in init or viewDidLoad
问题 In my UIViewController subclass should I initialize the NSArray of data for the UIPickerView in init or in viewDidLoad and why? Thanks. 回答1: I would call it in viewDidLoad as the view can be loaded more than once (and also be unloaded, hence you might also want to reload your array). Also, it's a good idea to load data lazily on iPhone most of the time. Loading data in viewDidLoad is much lazier than init , which might end up performing better for you if you init, but don't immediately use