Re: Determining if a method is a class or instance method
Re: Determining if a method is a class or instance method
- Subject: Re: Determining if a method is a class or instance method
- From: Philippe Mougin <email@hidden>
- Date: Mon, 12 Jul 2004 22:08:27 +0200
[...]
> These both rely on the fact that class objects are
> the only objects that are not members of their own
> class, because as the isMemberOfClass: documentation
> says, "Class objects are not 'members of' any class."
Note that the Cocoa documentation is wrong on this point. Actually,
class objects are 'members' of their class, and isMemberOfClass: will
correctly reports this. However, your code work because the "class"
method has not the same semantic for classes and non-classes objects.
For classes it returns the receiver instead of the class of the
receiver.
One way to get the class of a class is to use the objc_getMetaClass()
function defined in the Objective-C run-time.
Likewise, the documentation for the -(BOOL)isKindOfClass:(Class)aClass
method is also wrong. The doc states that:
"... when the receiver is a class object, this method returns YES if
aClass is NSObject, NO otherwise."
... which is not true: the implementation correctly returns YES when we
invoke this method on a class and pass the receiver's class (i.e. the
meta class) as argument.
Best,
Philippe Mougin
F-Script: open source interactive and scripting environment for Cocoa!
http://www.fscript.org
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.