Re: NSWindowController
Re: NSWindowController
- Subject: Re: NSWindowController
- From: Graham Cox <email@hidden>
- Date: Tue, 16 Sep 2008 13:57:26 +1000
On 16 Sep 2008, at 1:44 pm, Chris Idou wrote:
That fixes it, but I thought the owner in this case was the owner of
the NSWindowController, not the File's owner of the NIB.
-initWithWindowNibName:owner: expects you to pass the object that is
represented by File's Owner in the NIB. Typically this is the window
controller itself (in which case you can just use -
initWithWindowNibName:, which implicitly passes 'self' as owner) but
it need not be - it could be the document for example (personally I
think this usage is probably unusual). The point is you have to be
consistent - if you set up the NIB as if File's Owner is the
controller, but then pass a document or some other object as the
owner, there's a mismatch between your NIB and your code. Something's
going to give ;-)
NSWindowController has an "owner" property. But if you're saying the
owner is the File's owner, which is the NSWindowController itself,
then what is the owner property for?
If you design your nib with some other object in mind as File's Owner,
this object is returned by -owner. As I said I think it's unusual to
do this, but you may have a hierarchy of controllers where you'd
prefer them all to be managed by some common central object for
example. There may be other situations but I've never used it this way
so I don't know what they are. I suspect it would hinder the reuse of
your controller/nib elsewhere though they aren't often all that
reusable anyway.
cheers, Graham
_______________________________________________
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