hi,

why not try something like :

if ( [self isKindOfClass:[SuperClass class] ] )
{

}

so your test will not depend on instance but on 'typeof' 

usually in code you use 'super' to verify that some data in 'super' already 
exist or need to be initialised between testing super & self



Le 12 févr. 2011 à 14:52, Mikkel Eide Eriksen a écrit :

> Hi all,
> 
> I think I may have misunderstood something about how super works. In trying 
> to build a dictionary that contains key/value pairs from the class itself as 
> well as super classes up to an arbitrary height, I've hit a wall. Simplified, 
> I have two classes, SuperClass and SubClass. In SuperClass, the following 
> method is implemented:
> 
> -(NSDictionary *)tagDict
> {
>       NSMutableDictionary *dict = //built from plist, different for each class
>       if ([self class] == [SuperClass class]) {
>               return dict; // we don't go above our own root
>       }
>       
>       NSEnumerator *keyE = [[super tagDict] keyEnumerator]; //HERE
>       id key;
>       
>       while (key = [keyE nextObject]) {
>               [dict setValue:[[super tagDict] valueForKey:key]];
>       }
>       
>       return [dict copy];
> }
> 
> When this runs, it works fine if I call tagDict on an instance of SuperClass, 
> but if I try with SubClass, I get:
> 
> -[SubClass tagDict]: unrecognized selector sent to instance 0x20038efe0
> 
> But shouldn't it keep calling upwards until I reach the SuperClass, then stop 
> and return my finished dict? I see that it appears to be calling [SubClass 
> tagDict] which is the very method it's already in (so the selector can't very 
> well be unrecognized, or what?)...
> 
> Regards,
> Mikkel_______________________________________________
> 
> 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:
> http://lists.apple.com/mailman/options/cocoa-dev/clawfr59%40yahoo.fr
> 
> This email sent to clawf...@yahoo.fr

_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to