views:

20

answers:

1

I'm looking for a class in Objective C similar to C#'s KeyValuePair (even without the generics). Just anything that has a first/second object. I can create my own with no problem, but I figure if one is already there, then there is no need to re-invent the wheel. I have not had any luck findind one myself... Does anyone know of one?

+1  A: 

So basically like a hashmap, right?

Use NSMutableDictionary

Example from here:

NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] init]; 

// Add objects to a dictionary indexed by keys

[dictionary setObject:@"A Book about the Letter A" forKey:@"A"];
[dictionary setObject:@"A Book about the Letter B" forKey:@"B"];
[dictionary setObject:@"A Book about the Letter C" forKey:@"C"];

// Retrieve an object from a dictionary with a key

NSLog([dictionary objectForKey:@"B"]);

// Release a dictionary

[dictionary release];
mbrevoort
Like this, but only a single instance (hashmap/dictionary contain multiple key/values). I'm looking for a class that is just a single Key/Value.
Zenox