HashTables in Cocoa

You can try using an NSHashTable!


In addition to NSDictionary, also check out NSSet for when you need a collection with no order and no duplicates.


If you're using Leopard (and Cocoa's new Garbage Collection), you also want to take a look at NSMapTable.


NSDictionary and NSMutableDictionary?

And here's a simple example:

NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] init];
[dictionary setObject:anObj forKey:@"foo"];
[dictionary objectForKey:@"foo"];
[dictionary removeObjectForKey:@"foo"];
[dictionary release];