Re: Objective-C Question
Re: Objective-C Question
- Subject: Re: Objective-C Question
- From: Graham Cox <email@hidden>
- Date: Wed, 13 Mar 2013 00:37:05 +1100
On 12/03/2013, at 11:45 PM, Dave <email@hidden> wrote:
> Except it doesn't do what the above does!
Yes it does.
>>
>> @implementation DF2
>> + (NSDictionary*) dictionary
>> {
>> NSMutableDictionary* md = [[super dictionary] mutableCopy];
>> // add extra items to md
>> return [md autorelease];
>> }
>
> From reading the above, I cant see this is any better than what I have, it fact it copies the dictionary every time, which is not what is wanted as well as being slower.
Is it? Have you measured it? Does it matter?
In any case, it was only an example of how to achieve what you want, to show how to use class inheritance.
To be honest, the rest of your explanation doesn't make any sense to me, and I can't really be bothered to unravel it. Your whole "I can't instantiate the class" is incoherent at best (you *are* instantiating the class, like it or not). Maybe it makes sense to you, but not to me. I was trying to cut across all that irrelevant discussion by going back to basics and trying to get you to understand that:
a) [super class] is a meaningless construct, in that it doesn't do anything different from [self class],
b) in a class method, [self class] is just self,
c) a class method is just an ordinary instance method of the class object.
If you can understand those points, the rest should follow naturally. What you are trying to do is very straightforward, and requires no special trickery. The attempts you made show a clear lack of understanding about inheritance, which is what others were trying to tell you.
--Graham
_______________________________________________
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