Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (Newbie) How do Multiple NSWindowControllers find MyDocument?



On Aug 30, 2008, at 17:50, John Velman wrote:

So, if the button is pushed to bring up a new window, the IBAction is in
the master window controller. But the actual adding of the
NSWindowController and its associated window should be done by a method
back in MyDocument.


I can't find description of this part of the process.

The action in the existing window controller can create a new window controller, then invoke [self.document addWindowController: newWindowController]. That's all it should take.


Or, if the document needs to create the new window controller itself for some reason, implement the action to create the new window controller in your document class instead, and invoke [self addWindowController: newWindowController].

Note that the document and the window controllers are all effectively in the responder chain, so sending the button action to First Responder instead of a specific object will send the action to whichever object implements it.

One way I can think
of to do it is as follows:

In my MasterWindowController, have an instance variable called something
like "createdby", and a method "setCreatedby". Then in MyDocument, when I
alloc and init the instance of the masterWindowController, I follow
directly with [masterWindowController setCreatedby:self].

Window controllers already have a "document" outlet that is automatically set by [NSDocument addWindowController]. You don't need to roll your own.



_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >(Newbie) How do Multiple NSWindowControllers find MyDocument? (From: John Velman <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.