• 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: Sending a Selector to another Class.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sending a Selector to another Class.


  • Subject: Re: Sending a Selector to another Class.
  • From: Bill Bumgarner <email@hidden>
  • Date: Thu, 22 Oct 2009 08:53:08 -0700

On Oct 22, 2009, at 5:54 AM, Jim Kang wrote:

> However, a selector is not a string. I was just listening to this podcast
> with Mike Ash, and he discusses this around the 9:23 mark or so:
>
> http://podcast.mobileorchard.com/episode-23-mike-ash-on-the-objective-c-runtime-objects-and-the-runtime-message-sending-and-no-such-method/
>
> He explains that comparing strings is too slow for the runtime to use for
> finding messages and so it uses integers to represent the messages and calls
> them selectors.

Selectors are strings, but it is an implementation detail.

The runtime uniques the strings such that there is only ever one instance of, say, the "drawRect:" selector floating about.  Thus, the runtime can use pointer comparison to determine selector equality.

It is an implementation detail though.  One that is exceedingly unlikely to ever change but, still, an implementation detail.

Use the Objective-C runtime API if you want to do selector comparison.

sel_isEqual(), IIRC.

b.bum

_______________________________________________

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: Sending a Selector to another Class.
      • From: Jeff Johnson <email@hidden>
    • Re: Sending a Selector to another Class.
      • From: Jens Alfke <email@hidden>
References: 
 >Sending a Selector to another Class. (From: Joshua Garnham <email@hidden>)
 >Re: Sending a Selector to another Class. (From: Jim Kang <email@hidden>)
 >Re: Sending a Selector to another Class. (From: Jens Alfke <email@hidden>)
 >Re: Sending a Selector to another Class. (From: Jim Kang <email@hidden>)

  • Prev by Date: Re: stringWithContentsOfURL with resulting error 256
  • Next by Date: Re: NSTextField not getting mouseDown
  • Previous by thread: Re: Sending a Selector to another Class.
  • Next by thread: Re: Sending a Selector to another Class.
  • Index(es):
    • Date
    • Thread