Re: references to controllers in document based applications
Re: references to controllers in document based applications
- Subject: Re: references to controllers in document based applications
- From: Torsten Curdt <email@hidden>
- Date: Sat, 9 Feb 2008 23:09:12 +0100
On 09.02.2008, at 22:57, Kyle Sluder wrote:
On Feb 9, 2008 4:46 PM, Torsten Curdt <email@hidden> wrote:
How this started: I have a document based application and when I
click on a button in the document window I want to close the
document. AFAICS just calling close from within the NSDocument is not
enough
I can't understand why you think this to be the case... -[NSDocument
close] "closes all windows owned by the receiver and removes the
receiver from the list of documents maintained by the document
controller, which consequently releases it."
Yeah ...basically because when I call [self close] in my NSDocument
class - nothing happens :)
I also have an AppController class that I need to reference from my
documents. So this brought up a more general question. As the
document handling is encapsulated inside the NSDocumentController -
how do people usually do this? ...getting access to those instances
that are created and controlled by the framework.
Typically this is where the responder chain comes in.
http://developer.apple.com/documentation/Cocoa/Conceptual/
CocoaFundamentals/CoreAppArchitecture/chapter_7_section_6.html
Say you want a button in your document window to call a method on your
app delegate. You app delegate exists in your main nib, and your
button exists in your document window nib. What are you to do? Well,
since the application's delegate is in the responder chain, you wire
your button's target to the First Responder proxy object. When
clicked, the event dispatch mechanism keeps trying down the responder
chain until it finds an object that responds to the action selector.
Ahhh ...thanks for the link and the explanation!
cheers
--
Torsten
_______________________________________________
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