So, to answer your first question, the initializer that is called in this case is initWithCoder :, not init. Therefore, if you transfer NSArray initialization there to initWithCoder: you should find that it is available before loading your view.
Remember that you must also call the initializer of your superclass. Thus, such a template will work:
-(id)initWithCoder:(NSCoder *)aDecoder { if ((self = [super initWithCoder:aDecoder])) {
You will also get awakeFromNib after initWithCoder: and after all your points are connected, so if your initialization depends on the settlements, the ability to do initialization there.
And then, of course, you have viewDidLoad and viewWillAppear:. I do not know that there is a general answer to the โcorrectโ method of use (questions 2 and 4). It depends on how much data you have, how often you need to update and how long it takes to download. My opinion is that this decision should be made for each case.
To question number 3, do you have an example of what you saw there? The initializer will definitely be called before viewDidLoad. The trick is to know which initializer is being called.
Keep in mind that viewDidLoad can be called several times during the life of your view controller. So be prepared for this. And, of course, viewWillAppear: it will be called even more often several times during the life of your view controller.
Hope this helps.
source share