• 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: How to use "SEL"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to use "SEL"


  • Subject: Re: How to use "SEL"
  • From: Tomas Zahradnicky <email@hidden>
  • Date: Wed, 9 Oct 2002 08:12:57 +0200

I'm trying to write a general purpose loop method for one of my classes that takes as one of its parameters the selector of another method defined in the same class. Could someone fill in the blanks in the following snippet?

// Is this the right way to get a selector for a hypothetical "doFoo" method?

SEL theMethodSelector = [self selector:@selector( doFoo: )];



// and once I have the "SEL", I'd like to use it as follows

- (id) newWidget:(SEL) inSelector
{
// to actually use the selector what do I do?
[self performSelector:inSelector];
}

Hello Ken,

the message you're looking for is performSelector. Send this message to self to call a given SEL (doFoo:) in your case. The performSelector:, performSelector:withObject: and performSelector:withObject:withObject: are all defined in NSObject itself.

-Tomas
--
# Tomas Zahradnicky, Jr
# The Czech Technical University
# Dept of Computer Science, FEE-CTU Prague
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: How to use "SEL"
      • From: Ondra Cada <email@hidden>
References: 
 >How to use "SEL" (From: Ken Tozier <email@hidden>)

  • Prev by Date: Re: Can I get AppKit to draw this faster ?
  • Next by Date: Re: How to use "SEL"
  • Previous by thread: How to use "SEL"
  • Next by thread: Re: How to use "SEL"
  • Index(es):
    • Date
    • Thread