Re: Creating selector for nonexistent method
Re: Creating selector for nonexistent method
- Subject: Re: Creating selector for nonexistent method
- From: Quincey Morris <email@hidden>
- Date: Tue, 29 Apr 2014 10:59:31 -0700
On Apr 29, 2014, at 06:18 , Arved von Brasch <email@hidden> wrote:
> sendAction:to:from: seems to be the preferred way to invoke the responder chain to implement the clear: method in the Window controller.
This puzzles me. What are you actually trying to do?
If you’re trying to invoke *the* clear: method in the window controller, then ‘sendAction:to:from:’ seems like a bad choice. You don’t know if the window controller is even in the responder chain leading upwards from the current first responder, and you don’t know if other responders in the chain also implement ‘clear:’.
In other words, you’re essentially sending ‘clear:’ to a random receiver.
To send a message to the window controller specifically, you’d do better to get a reference to it, and send the message normally. If the window isn’t related to a NSDocument, it’s reasonable to let your app delegate have a reference to the window controller publicly available. If it’s a document window, you can look in the document’s ‘windowControllers’ array. Even something like ‘[[NSApplication main/keyWindow] windowController]’ (with a check on the window controller class) would be preferable.
If you’re trying to invoke *a* clear: method in any of several places in the responder chain, then ignore everything I just said.
_______________________________________________
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