• 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: How Do Classes Respond to performSelector?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How Do Classes Respond to performSelector?


  • Subject: Re: How Do Classes Respond to performSelector?
  • From: Quincey Morris <email@hidden>
  • Date: Wed, 30 Jan 2008 13:53:09 -0800


On Jan 30, 2008, at 13:14, Francisco Tolmasky wrote:

This is just a question out of curiosity. In the developer docs, only - (id)performSelector: is defined.
So I was going to write my own + (id)perfromSelector, but first figured I'd check whether there was
one already by writing up a quick test in XCode - which it turns out there is (saved me the work).
I figured it must just not be in the documentation, so I was going to file a bug on the developer docs...
Yet, doing a classdump on Foundation.framework doesn't show + performSelector either (only on
NSProxy, not on NSObject). Is there some magic going on? Is +performSelector actually not defined
on NSObject and this is getting forwarded to NSProxy or something? Or is this just a case of under
documentation and class dump not telling the whole truth?


Thanks,

Francisco

Someone already gave you the answer, but here's the money quote from the documentation, if you want to follow it up. From Cocoa Design Fundamentals/Cocoa Objects/The Root Class:


"Instance and Class Methods

"The runtime system treats methods defined in the root class in a special way. Instance methods defined in a root class can be performed both by instances and by class objects. Therefore, all class objects have access to the instance methods defined in the root class. Any class object can perform any root instance method, provided it doesn’t have a class method with the same name.

"For example, a class object could be sent messages to perform NSObject’s respondsToSelector: and performSelector:withObject:instance methods:
SEL method = @selector(riskAll:);
if ([MyClass respondsToSelector:method])
[MyClass performSelector:method withObject:self];"


An earlier paragraph states that NSObject and NSProxy are the two Cocoa-supplied root classes.


_______________________________________________

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


References: 
 >How Do Classes Respond to performSelector? (From: Francisco Tolmasky <email@hidden>)

  • Prev by Date: Re: How Do Classes Respond to performSelector?
  • Next by Date: How to ignore Tiger-only category methods on Leopard
  • Previous by thread: Re: How Do Classes Respond to performSelector?
  • Next by thread: How to ignore Tiger-only category methods on Leopard
  • Index(es):
    • Date
    • Thread