• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
viewDidLoad not called for an NSViewController's subclass (separate XIB)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: viewDidLoad not called for an NSViewController's subclass (separate XIB)
      • From: Ken Thomases <email@hidden>
  • Prev by Date: Re: NSSplitView in a separate NSWindowControl doesn't show for some reason
  • Next by Date: Re: viewDidLoad not called for an NSViewController's subclass (separate XIB)
  • Previous by thread: Re: Updated View Bounds After Orientation Change...
  • Next by thread: Re: viewDidLoad not called for an NSViewController's subclass (separate XIB)
  • Index(es):
    • Date
    • Thread