Re: Abusing targetForAction: with non-action selectors

2008-09-16 Thread Michael Ash
On Mon, Sep 15, 2008 at 7:49 PM, Charles Srstka <[EMAIL PROTECTED]> wrote: > On Sep 15, 2008, at 3:13 PM, Dave Dribin wrote: > >> Hello, >> >> Is it safe to use -[NSApplication targetForAction:] with non-action >> selectors? For example, selectors that have more than one argument, non-id >> first

Re: Abusing targetForAction: with non-action selectors

2008-09-15 Thread Dave Dribin
On Sep 15, 2008, at 6:56 PM, Graham Cox wrote: I think you have this a bit backwards, possibly. You still have to get notified when the first responder changes in order to tell your info panel to reorganise itself, so why not use that notification to directly obtain the correct target? Objec

Re: Abusing targetForAction: with non-action selectors

2008-09-15 Thread Graham Cox
On 16 Sep 2008, at 9:51 am, Dave Dribin wrote: I've got, say, an info panel that needs to display different stuff based on some object in the responder chain. What I really want to do is search the responder chain for an object that conforms to a specific protocol. I was just picking a m

Re: Abusing targetForAction: with non-action selectors

2008-09-15 Thread Dave Dribin
On Sep 15, 2008, at 6:35 PM, Graham Cox wrote: What exactly are you trying to do? I'd say it's not safe, since that usage isn't anticipated, or necessary. If you could perhaps outline why you think you need it a better solution can be suggested. I've got, say, an info panel that needs to d

Re: Abusing targetForAction: with non-action selectors

2008-09-15 Thread Charles Srstka
On Sep 15, 2008, at 3:13 PM, Dave Dribin wrote: Hello, Is it safe to use -[NSApplication targetForAction:] with non-action selectors? For example, selectors that have more than one argument, non-id first argument, or return values? The documentation for targetForAction:to:from: seems to

Re: Abusing targetForAction: with non-action selectors

2008-09-15 Thread Dave Dribin
On Sep 15, 2008, at 6:30 PM, Julien Jalon wrote: It's not safe... once the target is found (using respondsToSelector:, you're right), the action is performed with: [target performSelector:actionSelector withObject:sender]; which means that anything but an object as a sender will potentially

Re: Abusing targetForAction: with non-action selectors

2008-09-15 Thread Graham Cox
On 16 Sep 2008, at 6:13 am, Dave Dribin wrote: Is it safe to use -[NSApplication targetForAction:] with non-action selectors? For example, selectors that have more than one argument, non-id first argument, or return values? The documentation for targetForAction:to:from: seems to imply it

Re: Abusing targetForAction: with non-action selectors

2008-09-15 Thread Julien Jalon
It's not safe... once the target is found (using respondsToSelector:, you're right), the action is performed with:[target performSelector:actionSelector withObject:sender]; which means that anything but an object as a sender will potentially crash. The only safe thing you can image is to have an

Abusing targetForAction: with non-action selectors

2008-09-15 Thread Dave Dribin
Hello, Is it safe to use -[NSApplication targetForAction:] with non-action selectors? For example, selectors that have more than one argument, non-id first argument, or return values? The documentation for targetForAction:to:from: seems to imply it just does a respondsToSelector: on each