Re: [MyClass class] returning superclass's class
Re: [MyClass class] returning superclass's class
- Subject: Re: [MyClass class] returning superclass's class
- From: Ken Tozier <email@hidden>
- Date: Thu, 20 Nov 2008 09:03:36 -0500
On Nov 20, 2008, at 8:43 AM, Ken Thomases wrote:
You keep mentioning [MyClass class], except that's not what you're
calling. You're invoking -class (the instance method, rather than
the class method, by the way) on some object. That object is not an
instance of MyClass or, in the case of your actual code,
KOptionString.
I do understand the difference between a + method and - method, but
cut to many corners in the original question, which caused some
confusion. Oops.
In other words, class methods are just methods. There's no special
status regarding the class object to which you send them. There's
no rule or convention that, because you send a message to MyClass
and got an object back, that that object's class should be MyClass.
Let me ask you this: the return value from (random example) +
[NSPropertyListSerialization
dataFromPropertyList:format:errorDescription:] -- of what class
should that be? When you understand that there's no expectation
that it would be an instance of NSPropertyListSerialization, and you
understand how that's parallel to the behavior of +[KOptionString
whitespaceCharacterSet], then you'll see where you went wrong.
Excellent point. I hadn't thought of that.
- Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden