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: Robert Nicholson <email@hidden>
- Date: Mon, 12 Jul 2004 20:57:29 -0500
Are methods of a formal protocol guaranteed to be in the same linked
list?
On Jul 12, 2004, at 4:54 PM, Glenn Andreas wrote:
At 10:08 PM +0200 7/12/04, Philippe Mougin wrote:
[...]
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.
And if you're head isn't hurting yet, a meta-class is an NSObject.
(And let's not start discussing what a Protocol is...)
--
Glenn Andreas email@hidden mondo blobbo,
Cythera, Theldrow, oh my!
Mad, Bad, and Dangerous to Know
_______________________________________________
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.
_______________________________________________
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.