• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Abusing targetForAction: with non-action selectors
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Abusing targetForAction: with non-action selectors


  • Subject: Re: Abusing targetForAction: with non-action selectors
  • From: "Julien Jalon" <email@hidden>
  • Date: Tue, 16 Sep 2008 01:30:19 +0200

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 action selector with no
paramater at all.

--
Julien

On Mon, Sep 15, 2008 at 10:13 PM, Dave Dribin <email@hidden> 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 imply it just does
> a respondsToSelector: on each object in the responder chain, and it seems to
> behave this way in my tests.  I'd just like to make sure it is safe to rely
> on this behavior, or if we should find some other approach.
>
> Thanks,
>
> -Dave
>
> _______________________________________________
>
> 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
>
_______________________________________________

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

  • Follow-Ups:
    • Re: Abusing targetForAction: with non-action selectors
      • From: Dave Dribin <email@hidden>
References: 
 >Abusing targetForAction: with non-action selectors (From: Dave Dribin <email@hidden>)

  • Prev by Date: Re: Can't get to work setDoubleAction on NSMatrix with NSButtonCell
  • Next by Date: Re: Abusing targetForAction: with non-action selectors
  • Previous by thread: Abusing targetForAction: with non-action selectors
  • Next by thread: Re: Abusing targetForAction: with non-action selectors
  • Index(es):
    • Date
    • Thread