• 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: Determining if a method is a class or instance method
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


  • Follow-Ups:
    • Re: Determining if a method is a class or instance method
      • From: Glenn Andreas <email@hidden>
References: 
 >Re: Determining if a method is a class or instance method (From: Philippe Mougin <email@hidden>)
 >Re: Determining if a method is a class or instance method (From: Glenn Andreas <email@hidden>)

  • Prev by Date: Tracking openings of .rsrc files?
  • Next by Date: Re: Tracking openings of .rsrc files?
  • Previous by thread: Re: Determining if a method is a class or instance method
  • Next by thread: Re: Determining if a method is a class or instance method
  • Index(es):
    • Date
    • Thread