On Jan 30, 2008, at 1:14 PM, 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).
In Objective-C, a class object gets all the instance methods of the
root class for its hierarchy. This means that every class object
that descends from NSObject gets all of NSObject's instance methods -
including performSelector:.
This isn't a magic property of NSObject. Your own root classes do
this too:
#import <objc/objc.h>
@interface MyRootClass @end
@implementation MyRootClass
- (void)sayHi { puts("Hi!"); }
+ (void)initialize { /* Must be implemented */ }
@end