Re: Can't create windows with framework window nib
Re: Can't create windows with framework window nib
- Subject: Re: Can't create windows with framework window nib
- From: Michael Ash <email@hidden>
- Date: Sat, 21 Feb 2009 19:36:35 -0500
On Sat, Feb 21, 2009 at 5:12 PM, Tron Thomas <email@hidden> wrote:
> I found that if I derive a class from NSWindowController and use that in the
> frame work object then things work. It seems kind of silly to derive a
> class just for the purpose the inherited class doesn't implement anything
> above what NSWindowController offers, and is just simple a wrapper to define
> the class as a new type.
>
> Why does something like this work?
> What is the best way to solve this problem?
>From the documentation for -[NSWindowController loadWindow]:
"It uses NSBundle's bundleForClass: method to get the bundle, using
the class of the nib file owner as argument."
A nib name is insufficient to find a nib; the system would have no
idea which of the dozens of loaded frameworks is supposed to contain
it. It needs to know which bundle to look in. Since you don't tell it,
it guesses by using the bundle associated with the class of the
NSWindowController instance. When you subclass it, that's your bundle.
When you don't, that's AppKit.framework and it has no such nib.
The obvious workaround is to locate the nib yourself (using NSBundle
methods, for example) and then use -[NSWindowController
initWithWindowNibPath:owner:].
Mike
_______________________________________________
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