I have a situation where I want to map a pair of objects to a dictionary of information. I’d like to avoid creating an NSDictionary of NSDictionaries of NSDictionaries since that’s simply confusing and difficult to maintain.
For instance if I have two classes, Foo and Bar, I want {Foo, Bar} -> {NSDictionary}
Are there other options than just making a custom class (just to be used as the dictionary key) based on the two types in question? Maybe something akin to STL’s pair type that I just don’t know about?
Like you said, you can create a Pair class:
Edit:
Some notes on creating objects that can be keys:
NSCopyingprotocol, since we don’t want the key to change out from underneath us.isEqual:. I implement thehashmethod for good measure, but it’s probably not necessary.