• 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: isKindOfClass vs. loading bundles: nope?!?!?!?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: isKindOfClass vs. loading bundles: nope?!?!?!?


  • Subject: Re: isKindOfClass vs. loading bundles: nope?!?!?!?
  • From: Andy Lee <email@hidden>
  • Date: Thu, 21 Mar 2002 13:28:24 -0500

At 5:50 PM +0100 3/21/02, John Hvrnkvist wrote:
Strictly speaking, no, instance methods are never class methods.
What is true is that variables of type Class respond to NSObject
instance methods by virtue of the fact that they are treated as
quasi-objects.

All instance methods of a _root class_ are also class methods.
That's something you have to know, and deal with, when you're
writing root classes.

I stand corrected again, I suppose, though this sounds odd. What happens if you give a root class a class method with the same name as an instance method? I've never written a root class, and my impression is there's some black art involved.

A variable of type Class (with a capital C) is not an instance of
*any* class, so -isKindOfClass: is giving you the right answer.

A class object is just like any other object; it's an instance of
some meta class. That's part of the beauty of Objective-C.

Not to split hairs, but an Objective-C metaclass is not an Objective-C class. A variable of type Class can be messaged like any other object, but is not itself an instance of any class (or of any Class, if you like).

I haven't read the language spec -- I'm just going by lessons long past and poorly remembered -- so I won't argue too hard about semantics. My point was that to understand why -isKindOfClass: didn't do what Ondra expected, you have to understand WHY the expression...

[[anInstanceOfMyClass class] isKindOfClass:Foo]

...is very different from...

[MyClass isKindOfClass:Foo]

...which is almost meaningless, as it will always return NO. I want to emphasize to Ondra that this is not a bug or flaw in Objective-C or Apple's implementation thereof. It is consistent with the class/instance distinction in Objective-C.

--Andy
_______________________________________________
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.

References: 
 >Re: isKindOfClass vs. loading bundles: nope?!?!?!? (From: John Hörnkvist <email@hidden>)

  • Prev by Date: NSTextView and setString
  • Next by Date: toplevel window from an object
  • Previous by thread: Re: isKindOfClass vs. loading bundles: nope?!?!?!?
  • Next by thread: Re: isKindOfClass vs. loading bundles: nope?!?!?!?
  • Index(es):
    • Date
    • Thread