Hi

I'm trying to create an NSDictionary that uses key based upon the contents of a NSSet (specifically a set of NSManagedObjectID's). I'm currently at a bit loss as to how to do it. My various attempts at a hash based solution (see below) don't appear to be working.

I don't suppose anyone could give me some pointers on a better way to approach this problem; i.e. should I be subclassing the NSSet and repointing it's isEqual: method to isEqualToSet: ?

Cheers

Tim



NSUInteger hashInt=0;
        
for (SDTCharacteristicType *characteristicType in characteristicTypes)
{
        hashInt = hashInt ^ [[characteristicType objectID] hash];
}
        
NSString *hashFromCharacteristicTypes = [NSString stringWithFormat: [[NSNumber numberWithInteger:hashInt] stringValue]];

if ([setOfValuesForCharacteristicTypes containsObject:hashFromCharacteristicTypes])
{
return [dictionaryOfValuesForCharacteristicTypes objectForKey:hashFromCharacteristicTypes];
}
else
{
        // this section does the actual work of finding the values to return
        
        ....
        code to
        ....

[dictionaryOfValuesForCharacteristicTypes setObject:valuesToReturn forKey:hashFromCharacteristicTypes ]; [setOfValuesForCharacteristicTypes addObject:hashFromCharacteristicTypes];
        
        return valuesToReturn;
}


______________________________________________
Tim McDonald

Dept of Mechanical Engineering
University College London


_______________________________________________

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