Re: I want a window's file owner that's not a NSWindowController
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: Ken Thomases <email@hidden>
- Date: Wed, 29 Sep 2010 06:47:13 -0500
On Sep 29, 2010, at 3:21 AM, Jonny Taylor wrote:
> 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.
You should be using an NSWindowController, anyway. NSWindowController performs important services for you, like memory management of the top-level objects in the NIB and breaking retain cycles for bindings through File's Owner. You could take care of these yourself, but it's tedious and error-prone.
http://developer.apple.com/library/mac/#documentation/cocoa/Conceptual/MemoryMgmt/Articles/mmNibObjects.html
See the class reference for NSViewController for an oblique reference to the binding retain cycle fix in NSWindowController.
Regards,
Ken
_______________________________________________
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