Re: isKindOfClass vs. loading bundles: nope?!?!?!?
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.