• 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
Passing selectors as Arguments (Was: - (void)sortUsingSelector:(SEL)comparator )
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Passing selectors as Arguments (Was: - (void)sortUsingSelector:(SEL)comparator )


  • Subject: Passing selectors as Arguments (Was: - (void)sortUsingSelector:(SEL)comparator )
  • From: "David P. Henderson" <email@hidden>
  • Date: Wed, 25 Jul 2001 15:07:16 -0400

On Wednesday, July 25, 2001, at 01:58 , Dennis C. De Mars wrote:

> The @selector is a compiler directive (described in the Obj-C manual)
> that takes the
> name of the selector as an argument and returns a value of type SEL
> which is the
> internal Objective C representation of the selector. You always have to
> use it when you
> are passing selectors as arguments.
>
The last line of this statement is not completely true; you can also do
the following:

SEL aSel = @selector(doSomething); // Uses the @selector directive
SEL anotherSel = NSSelectorFromString(@"doSomethingElse"); // Makes a
selector from a string

Which allows you to pass the variables without using the @selector
directive, but using the directive is often the simplest, easiest way to
pass a method as an argument. The above are more useful if you need to
use the selector more than a few times, and I'll leave it for the
uninitiated to discover how truly useful it can be to have a function
like NSSelectorFromString().

Dave
--
Chaos Assembly Werks
"Imagination is more important than knowledge."
- Albert Einstein


  • Follow-Ups:
    • Re: Passing selectors as Arguments (Was: - (void)sortUsingSelector:(SEL)comparator )
      • From: Marcel Weiher <email@hidden>
    • Re: Passing selectors as Arguments (Was: - (void)sortUsingSelector:(SEL)comparator )
      • From: "Dennis C. De Mars" <email@hidden>
References: 
 >Re: - (void)sortUsingSelector:(SEL)comparator (From: "Dennis C. De Mars" <email@hidden>)

  • Prev by Date: Cursor color
  • Next by Date: Re: Cursor color
  • Previous by thread: Re: - (void)sortUsingSelector:(SEL)comparator
  • Next by thread: Re: Passing selectors as Arguments (Was: - (void)sortUsingSelector:(SEL)comparator )
  • Index(es):
    • Date
    • Thread