Re: Sending a Selector to another Class.
Re: Sending a Selector to another Class.
- Subject: Re: Sending a Selector to another Class.
- From: Jim Kang <email@hidden>
- Date: Thu, 22 Oct 2009 08:54:39 -0400
Jens, thanks for clearing up the thing about the selector defining a message
(method plus parameters) rather than a method and thus not being tied to a
class.
On Thu, Oct 22, 2009 at 1:21 AM, Jens Alfke <email@hidden> wrote:
>
> On Oct 21, 2009, at 9:43 AM, Jim Kang wrote:
>
> That selector is a unique index that points to a method of a specific
> class.
>
>
> No, that's not true of Objective-C (although it is of C++ method-pointers.)
> A selector is, basically, just a unique string: it defines a *message*,
> not a method, to use the old Smalltalk OOP terminology.
>
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.
> Any class that implements a method with that name uses the same selector
> for it, regardless of inheritance.
>
> To be specific, if I create two unrelated classes A and B, each of which
> implements a -foo method, the selector @selector(foo) is used for both.
>
This is really good to know.
_______________________________________________
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