I've done some testing, but I just can't make this work...
I have an NSWindowController that manages a pop-up window and a button in the main window that launches the pop-up window when it's pressed. I need to pass a managedObjectContext to the window controller.
If I create the NSWindowController programmatically with a custom initializer:
NSWindowController *myWindowController = [[NSWindowController alloc] initWithWindowNibName:@"MyWindow" moc:self.managedObjectContext];
everything works fine. I can also pass the managedObejctContext separately without breaking anything.
But, things fall apart when I try to add the window controller to the main window's nib. Once I add an object for the window controller in the main window's nib and set its class to NSWindowController, the app uses NSWindowController's designated initializer, initWithWindow to initialize the window controller.
By default, NSWindowController contains an outlet for its window. If I connect the NSWindowController's window outlet to the pop up window and add an NSLog to the initWithWindow method asking for NSWindowController's self.window, it comes back null and the window doesn't load.
It seems like the connection in the pop up window's nib file from File's Owner (the NSWindowController) outlet to the window is not being honored. Even if I create another outlet (oWindow), connect it to the window controller and try to set it in initWithWindow with:
- (id)initWithWindow:(NSWindow *)window { if (self == [super initWithWindow:self.oWindow]) { //NSLog(@"Window is %@", self.window); NSLog(@"MOC is %@", self.mMainManagedObjectContext); self.window.title = @"New Account"; } return self; } it fails. How can I make this work? Thanks. Brad _______________________________________________ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com