• 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: 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.


  • Follow-Ups:
    • Re: Determining if a method is a class or instance method
      • From: Glenn Andreas <email@hidden>
  • Prev by Date: Re: Storing C objects (structs) in NS Containers?
  • Next by Date: NSTableView delegate not getting called
  • Previous by thread: 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