viewDidLoad not called for an NSViewController's subclass (separate XIB)
viewDidLoad not called for an NSViewController's subclass (separate XIB)
- Subject: viewDidLoad not called for an NSViewController's subclass (separate XIB)
- From: Nick <email@hidden>
- Date: Sun, 25 Oct 2015 08:58:34 +0200
Hi.
I am having a weird problem that viewDidLoad isn't called. Actually it's
not a problem - I can use -awakeFromNib initializator instead, but I am
wondering why viewDidLoad is not called (as it is automatically generated
by xcode with a comment "place your initialization code here", when I
create a new View Controller with a XIB)?
Here's what I am doing.
I created a new Xcode non-storyboard project, created an NSViewController's
subclass with a XIB (let's call it MyVC), and added the following code to
the app delegate:
static MyVC *myVC;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
myVC = [[MyVC alloc] initWithNibName:@"MyVC" bundle:nil];
[myVC loadView];
self.window.contentView = myVC.view;
}
*inside MyVC.m I have *
@implementation MyVC
- (void)viewDidLoad {
[super viewDidLoad];
NSLog(@"%@ viewDidLoad", [self className]);
// Do view setup here.
}
- (void)awakeFromNib {
[super awakeFromNib];
NSLog(@"%@ awakeFromNib", [self className]);
}
@end
When I run the project, only "MyVC awakeFromNib" is printed out. Why
viewDidLoad isn't called?
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden