Re: Another Gnarly Objective-C Question!
Re: Another Gnarly Objective-C Question!
- Subject: Re: Another Gnarly Objective-C Question!
- From: Wim Lewis <email@hidden>
- Date: Tue, 12 Mar 2013 17:55:40 -0700
On 12 Mar 2013, at 2:08 AM, Graham Cox wrote:
> in a + method, [self class] === self. Once you've got that, you've got it.
>
>
>
> You're overthinking this.
>
> A class method is just an instance method of the class object. No magic at all. So all this confusion you've caused yourself about [super class] and so on is wholly unnecessary to correctly use class methods.
To be very slightly pedantic, the only magic here is 'super' --- sending a message to super (which you can only do from a method implementation) is special syntax that searches for the method starting with the implementation's class's superclass, rather than at the receiver's actual class. Everything else is non-magic. (In general, that's been one of the strengths of ObjC: very little magic.)
But since there's only one relevant implementation of +class (on NSObject), and it returns self, and self is the same object regardless of how the method implementation was found, [self class] and [super class] are equivalent.
_______________________________________________
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