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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to