• 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
Easy Question re NSWindowController
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Easy Question re NSWindowController


  • Subject: Easy Question re NSWindowController
  • From: Brad Gibbs <email@hidden>
  • Date: Sat, 05 Sep 2009 05:42:35 -0700

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 (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: Easy Question re NSWindowController
      • From: Graham Cox <email@hidden>
    • Re: Easy Question re NSWindowController
      • From: Steven Degutis <email@hidden>
  • Prev by Date: Re: Services Menu in Snow Leopard
  • Next by Date: Re: Easy Question re NSWindowController
  • Previous by thread: Re: subclassing with conditional method overriding
  • Next by thread: Re: Easy Question re NSWindowController
  • Index(es):
    • Date
    • Thread