• 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: Joshua Garnham <email@hidden>
  • Date: Thu, 22 Oct 2009 05:52:37 +0000 (GMT)

Ah, I see. so I need to send it to an instance of the class not the class it self.
How would I do that?


Thanks,
Josh.


________________________________
From: Jens Alfke <email@hidden>
To: Jim Kang <email@hidden>
Cc: Joshua Garnham <email@hidden>; email@hidden
Sent: Thursday, 22 October, 2009 6:21:29
Subject: Re: Sending a Selector to another Class.



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. 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.

Joshua's problem was, apparently, that he was trying to send an message to a class object instead of an instance, but the corresponding method was defined on instances, not the class.

—Jens



_______________________________________________

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: Rob Keniger <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>)

  • Prev by Date: NSTokenField with both non-editable and editable tokens
  • Next by Date: "Sticky" Event tracking
  • Previous by thread: Re: Sending a Selector to another Class.
  • Next by thread: Re: Sending a Selector to another Class.
  • Index(es):
    • Date
    • Thread