On Mar 11, 2013, at 1:45 PM, Dave <d...@looktowindward.com> wrote: > On 11 Mar 2013, at 20:30, Seth Willits wrote: >> On Mar 11, 2013, at 1:21 PM, Dave wrote: >> >>> +(NSMutableDictionary*) newDict >>> { >>> return [[NSMutableDictionary alloc] init]; >>> } >> >> (I hope you're using ARC otherwise this is a memory leak.) >> > > Yes, but it's only an example so don't worry about that, and, anyway, it > isn't necessarily a leak, it will only leak if no one releases it in Non-Arc > and since the method is named correctly, it will cause an analyzer warning if > it is not released. > > >>> myDict = [[super class] newDict]; >> >> This should be [super newDict]. > >> -- Seth > > > Surely that would call the Instance Method (and there isn't one), I think the > correct code is: > > [[self superclass] newDict]; > > as someone else all ready said.
[super foo] sends 'foo' to 'self', but doing lookup starting in the superclass of the class P which provided this method. If you are currently defining an instance method of class C, P is C, and so the super lookup finds methods of C, which are instance methods. If you are currently defining a class method of class C, however, P is C's metaclass, and so the super lookup finds methods of C's metaclass, which are class methods (unless there is no class method in the hierarchy with that selector, in which case it might be an instance method of the root class, because the root class's metaclass is a subclass of the root class). John. _______________________________________________ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com