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: Michael Babin <email@hidden>
- Date: Sun, 10 Feb 2008 01:39:45 -0600
On Feb 9, 2008, at 11:09 PM, Paul Bruneau wrote:
If I may butt in, which way is better? I have one app mostly under
my belt and I started out creating outlets in my classes for my
appController. I got the idea that was bad so I started doing
[[[NSApp] delegate] aMethodInMyAppController]. In a view I have I
even did something like (this is from memory) [[[self window]
delegate] aMethodOfTheWindowController] to get from the view, to its
window, to the window's controller.
In the context of determining the action associated with a control, I
would recommend nil-targeted actions where appropriate. They allow you
to determine independently where to implement the corresponding action
and allow you to override the behavior at lower levels in the
responder chain, if needed. Also makes it easier if you decide to move
the action implementation to a different level in your responder chain
(less maintenance).
But it sounds like I can just do [self aMethodOfTheWindowController]
directly from my view provided that the responder chain is set up
properly? I wonder if the compiler complains about the view possibly
not being able to respond to the window controller's methods? I
can't wait to try it out on Monday! I knew I was doing things
questionably so having this thread appear is weekend gold!
I think you're confusing setting the target of a control (part of the
target-action pair) to nil, which propagates the action up the
responder chain, with being able to send a message to an object (part
of the responder chain) and having it automatically propagated up the
responder chain. The former case works. The latter doesn't.
In general, minimizing the interdependencies between objects is
desirable. But sometimes there is some piece of data that you need to
access or some state/action you need to set/take that properly resides
at the application level. For those cases, accessing the application
controller through [NSApp delegate] is a convenient method to use.
- Mike
_______________________________________________
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