• 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: call selector @"mySelector"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: call selector @"mySelector"


  • Subject: Re: call selector @"mySelector"
  • From: Sherm Pendley <email@hidden>
  • Date: Fri, 30 Sep 2005 15:27:11 -0400

On Sep 30, 2005, at 10:07 AM, Jim Correia wrote:

On Sep 30, 2005, at 9:19 AM, Aaron Wallis wrote:

I was wondering how I would go about getting cocoa to call a selector defined in a string?

You don't "call a selector," you send a message.

SEL selector = NSSelectorFromString(@"aSelector");

[object performSelector: selector withObject: nil];

In addition, if the method in question takes more than two arguments, or takes and/or returns a non-object type, there's NSInvocation. It's more complex, but it's capable of handling any number and type of arguments, and any type of return value.


sherm--

Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: call selector @"mySelector"
      • From: Raffael Cavallaro <email@hidden>
References: 
 >call selector @"mySelector" (From: Aaron Wallis <email@hidden>)
 >Re: call selector @"mySelector" (From: Jim Correia <email@hidden>)

  • Prev by Date: Re: API for Modifying Dock Contents
  • Next by Date: Moving Focus Ring
  • Previous by thread: Re: call selector @"mySelector"
  • Next by thread: Re: call selector @"mySelector"
  • Index(es):
    • Date
    • Thread