Re: multi-window document best practices?
Re: multi-window document best practices?
- Subject: Re: multi-window document best practices?
- From: "email@hidden" <email@hidden>
- Date: Sat, 12 May 2012 19:11:15 -0700
On May 12, 2012, at 5:55 PM, Kyle Sluder wrote:
> You are correct that nothing in the docs prohibits passing the document as the file's owner argument for window controllers you construct yourself. And in the case of a single window controller, it might workâthough this is not guaranteed.
Huh. In NSDocument.h, it is written "The default implementation of (makeWindowControllers) ... creates a new window controller ..., specifying this document as the nib file's owner..."
Presumably, Apple is telling us this so we know how to do it ourselves. If this is a pattern we ought not emulate, this would be an ideal place to mention that.
> But if you have two or more window controllers, and you need to set the window for each of them, then clearly the document's window property is not the appropriate place for this.
It's not at all clear.
> And it will result in multiple -awakeFomNib: messages being sent to your NSDocument.
Heh, assuming awakeFromNib will only ever be called once is a newbie mistake I've made more than once ;)
I presume you meant windowControllerDidLoadNib: not awakeFromNib. I would *expect* multiple windowControllerDidLoadNib: calls, once for each nib loaded. That's perhaps why windowControllerDidLoadNib: has a windowController arg; so you can know which nib is being loaded and act appropriately.
> The document-loads-nib pattern is explicitly documented as a convenience wrapper around creating your own NSWindowController instance.
Yes, it is convenient.
> The window outlet on NSDocument exists solely for the purpose of supporting this convenience.
I don't think so. I think it's there to support the convenience of having the nib's file's owner be the document, just like it is in the single window case.
If it were important that nibs should be built differently for single and multiple window cases, I'd think the docs would mention it someplace, but they don't.
_murat
_______________________________________________
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