On 11 Mar 2013, at 20:21, Dave <d...@looktowindward.com> wrote: > Hi, > > Take the following example: > > @interface BaseClass > > +(NSMutableDictionary*) newDict; > > @end > > @implementation BaseClass > > +(NSMutableDictionary*) newDict > { > > > return [[NSMutableDictionary alloc] init]; > } > > > @class NewClass; > > @interface NewClass : BaseClass > > +(NSMutableDictionary*) newDict; > > @end > > #import "BaseClass.h" > > @implementation NewClass > > +(NSMutableDictionary*) newDict > { > NSMutableDictionary* myDict; > > myDict = [[super class] newDict]; > [myDict setObject:@"Some Data" forKey:@"someKey"]; > > return [[NSMutableDictionary alloc] init]; > } > > @end > > > > > I had assumed (and I thought I'd done something like this before) that the: > > myDict = [[super class] newDict]; > > statement would call newDict in BaseClass???? Instead it calls the version in > NewClass and goes into an infinite loop!!
Yes. [super class] calls super's implementation of the -class method. You haven't overridden -class, so it does the same thing as [self class]. People often make the same mistake in trying to do [super respondsToSelector… I'm guessing what you're really after is [[self superclass] newDict] _______________________________________________ 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