Reputation:
The App Delegate has an outlet property to the view controller, and the view controller is created in the nib.
Althoug the -viewDidLoad method of the view controller gets loaded, it seems that it designated initializer receives no call:
- (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle {
NSLog(@"iniwinib");
if (self = [super initWithNibName:nibName bundle:nibBundle]) {
// do stuff
}
return self;
}
I also tried with -init, but this also does not receive a call. No NSLog output. Is there another initializer that I must use in this case?
Upvotes: 3
Views: 462
Reputation: 22405
Are you actually calling initWithNibName to create your ViewController somewhere in the code? If not then it will never get called, this method does not get called automatically you must call it to create your viewController from your nib. But you dont need to do call this method because you have already set the ViewController in the nib..
Upvotes: 0
Reputation: 299575
-initWithCoder:
is the initializer in this case (because the object is being deserialized from the NIB), but the routine you actually want here is -awakeFromNib
. That's what's called after all the objects in the NIB have been constructed and all the outlets have been wired.
Upvotes: 9