On Nov 20, 2008, at 7:52 AM, Ken Tozier wrote:
I guess if you never instantiate any actual objects then Andy
"proved" it, but try to create an object using one of the
superclass's methods and I think I proved that it doesn't in fact
return expected results.
As Jean-Daniel said, this is a class cluster and a "feature" of the
class cluster implementation, but it is highly counterintuitive.
[MyClass class] should return the class used to instantiate an
object, not some undocumented mystery class somewhere in a class
cluster.
I actually didn't realize NSCharacterSet is a class cluster, I was
merely trying to reproduce the exact problem you described. Surely
you realize [MyClass class] is different from
[anInstanceOfMyClassOrPossiblyASubclass class].
I got it working for my purposes by embedding an NSCharacerSet as a
property of MyClass, so all is good, but [MyClass class] returning
an undocumented class is wrong, in my opinion.
The very point of class clusters is that [[Foo foo] class] doesn't
necessarily return Foo or indeed any documented class when Foo is a
class cluster. It's only unintuitive and wrong if you don't realize
that.
The motivation for class clusters is explained here:
<http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaObjects/chapter_3_section_9.html
>
As a side note, if your design requires you to check for an exact
value of [myObject class], maybe there's a better way? I can't say
for sure without knowing what you're trying to do.
--Andy
_______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [EMAIL PROTECTED]