Collection Classes iOS 6.0


Do you have any insight to why NSHashTable and NSMapTablew only became available in iOS 6.0?

NSHashTable etc have a checkered past. Originally they were fake-objects. If you look in NSHashTable.h you’ve got this “Legacy” area:

[code]typedef struct {
NSUInteger (*hash)(NSHashTable *table, const void *);
BOOL (*isEqual)(NSHashTable *table, const void *, const void *);
void (*retain)(NSHashTable *table, const void *);
void (*release)(NSHashTable *table, void *);
NSString *(*describe)(NSHashTable *table, const void *);
} NSHashTableCallBacks;

FOUNDATION_EXPORT NSHashTable *NSCreateHashTableWithZone(NSHashTableCallBacks callBacks,
NSUInteger capacity, NSZone *zone);

And a lot of C functions where you passed an NSHashTable as the first argument.

Then came garbage collection, and Apple wanted to introduce containers that could handle zeroing weak references. NSHashTable originally wasn’t an object, so its name was used to be one of those collections. iOS never got garbage collection, so the collection was never ported.

I figure Apple ported the stuff to ARC (I personally haven’t really used NSHashTable for anything since I didn’t work on any big GC projects), and it was ready for prime time in the ios6 time frame.