views:

16

answers:

1

I'm looking for a better way to do this:

id key, value;
NSMutableDictionary dict;
[dict setObject:value forKey:[NSNumber numberWithInt:(int)key]]

That is, use an NSDictionary to map from address to object.

A: 

If you can, use C++'s map:

std::map<id, id> map;
map.insert(std::make_pair(key, value));

You'll have to change the file's extension to .mm. Also note that it will not retain your values.

Aleph
std::map isn't a hashtable...
nornagon
then std::unordered_map, just include ``tr1/unordered_map``
Aleph