• 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
Re: I want a window's file owner that's not a NSWindowController
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: I want a window's file owner that's not a NSWindowController


  • Subject: Re: I want a window's file owner that's not a NSWindowController
  • From: Jonny Taylor <email@hidden>
  • Date: Wed, 29 Sep 2010 09:21:34 +0100

> Quincey Morris wrote:
>> You're kind of mixing up two different tasks here. The Camera object is (likely) part of your data model (in the MVC paradigm). A window controller is a ... controller. For your settings window, you'll have least heartache if you make the NIB's File's Owner a window controller. Window controllers are *designed* to be the owners of NIB files.
>>
>> So, subclass NSWindowController, and add a "camera" property. (Your Camera object can pass its 'self' pointer as a parameter to the window controller subclass's init... method.)
>>
>> Then, to get at Camera properties, objects in the NIB can bind to File's Owner.camera.whateverProperty -- instead of File's Owner.whateverProperty as you have now.
> Ah, that is quite a neat solution - thanks for that. I hadn't twigged that I could do that sort of "property of a property" binding. It still seems a bit of a faff to create a controller subclass that isn't really doing anything other than passing through property requests, but at least I don't have do write accessors for every property I want to get at in the Camera object!

OK, while that's a very handy thing to know, I think I have worked out a simpler way that does not require an intermediate class - I'll state it here for the archives (and any comments welcome...)

I show the window using the following code:
@implementation Camera
-(void)showSettingsWindow
{
	if (settingsWindowController == NULL)
		[NSBundle loadNibNamed:@"Camera Settings" owner:self];
	[settingsWindowController showWindow:self];
}
@end

... and the NIB file (File's Owner = Camera) contains the window and a controller object (linked together), with the window controller linked to the outlet "settingsWindowController" in File's Owner placeholder.

Jonny_______________________________________________

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: I want a window's file owner that's not a NSWindowController
      • From: Ken Thomases <email@hidden>
References: 
 >I want a window's file owner that's not a NSWindowController (From: Jonny Taylor <email@hidden>)
 >Re: I want a window's file owner that's not a NSWindowController (From: Quincey Morris <email@hidden>)
 >Re: I want a window's file owner that's not a NSWindowController (From: Jonny Taylor <email@hidden>)

  • Prev by Date: Re: NSMutableDictionary crash on PPC
  • Next by Date: Background-Task (Timer)
  • Previous by thread: Re: I want a window's file owner that's not a NSWindowController
  • Next by thread: Re: I want a window's file owner that's not a NSWindowController
  • Index(es):
    • Date
    • Thread