loading NSWindowController nib from bundle
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