• 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
loading NSWindowController nib from bundle
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

loading NSWindowController nib from bundle


  • Subject: loading NSWindowController nib from bundle
  • From: Torsten Curdt <email@hidden>
  • Date: Mon, 27 Oct 2014 23:10:05 +0100

I am a little confused on how to load NSWindowController from a bundle
other than the mainbundle.

While this code works just fine

    controller = [[self alloc] initWithWindowNibName:@"TCAboutWindow"];

I now moved the the nib into it's own bundle inside the main bundle.
Since I could not figure out a better way I tried this:

        NSString *bundlePath = [[NSBundle mainBundle]
pathForResource:@"ResourceBundle"
ofType:@"bundle"];

        NSString *nibPath = [[[bundlePath
           stringByAppendingPathComponent:@"Contents"]
           stringByAppendingPathComponent:@"Resources"]
           stringByAppendingPathComponent:@"TCAboutWindow.nib"];

        controller = [[self alloc] initWithWindowNibPath:nibPath
owner:self];

and now I quickly realised that (for the owner) "self" in this context is
not the "self" when calling

    controller = [[self alloc] initWithWindowNibName:@"TCAboutWindow"];

Now I am confused as the controller has the outlets and should be the owner.
Yet I can only pass it in to the initialiser when it doesn't even exist yet.

My first thought was that passing in "nil" as the owner would actually
default to "self" I really want - but that does not seem to be the case.

On the next thought

    controller = [self alloc];
    controller = [controller initWithWindowNibPath:nibPath
owner:controller];

seems to work - but feels like I am missing something.

Am I?

cheers,
Torsten
_______________________________________________

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: loading NSWindowController nib from bundle
      • From: Quincey Morris <email@hidden>
  • Prev by Date: Re: NSSavePanel load error
  • Next by Date: Mac containment segues, and prepareForSegue
  • Previous by thread: Using multiple cell XIBs for one UITableView - getting cell height.
  • Next by thread: Re: loading NSWindowController nib from bundle
  • Index(es):
    • Date
    • Thread