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 <j...@mooseyard.com> 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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to