• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSDictionary key from the content of a set
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSDictionary key from the content of a set


  • Subject: NSDictionary key from the content of a set
  • From: Tim McDonald <email@hidden>
  • Date: Thu, 15 Jan 2009 11:40:31 +0000

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 (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


  • Follow-Ups:
    • Re: NSDictionary key from the content of a set
      • From: Benjamin Stiglitz <email@hidden>
  • Prev by Date: Filtering NSPopUpButtonCell when clicking on it
  • Next by Date: Re: WebView (Caching)
  • Previous by thread: Re: ObjC in time-critical parts of the code
  • Next by thread: Re: NSDictionary key from the content of a set
  • Index(es):
    • Date
    • Thread