Re: multi-window document best practices?
Re: multi-window document best practices?
- Subject: Re: multi-window document best practices?
- From: Kyle Sluder <email@hidden>
- Date: Sat, 12 May 2012 17:55:58 -0700
On May 12, 2012, at 5:42 PM, "email@hidden" <email@hidden> wrote:
> On May 12, 2012, at 4:45 PM, Kyle Sluder wrote:
>
>> Document-as-File's-Owner only makes sense if you aren't overriding -makeWindowControllers.
>
> I don't think that's the case. Certainly nothing in the docs suggest it.
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.
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. And it will result in multiple -awakeFomNib: messages being sent to your NSDocument.
The document-loads-nib pattern is explicitly documented as a convenience wrapper around creating your own NSWindowController instance. The window outlet on NSDocument exists solely for the purpose of supporting this convenience. I wouldn't be surprised if Apple's only anticipated use of the 'owner' argument of NSWindowController's initializer is also to support this convenience.
If you were to remove NSDocument from this equation entirely, it wouldn't make sense to pass anything other than the window controller as the File's Owner. Since you're not taking advantage of NSDocument's default NSWindowController instance, you probably shouldn't rely on pieces of that functionality to support your app.
(The rest of your post seems to imply you have come to the same understanding.)
--Kyle Sluder
_______________________________________________
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