Separate names with a comma.
Discussion in 'iOS Programming' started by patrover, Aug 22, 2009.
NSDictionary is a dictionary, though only from the developers perspective, if its more efficient to be stored as a hash table it probably is. Just like NSArray has log(n) access times - it just appears to the developer to be array-like.
from what i've read NSDictionary is implemented with a hash table
Yes, it maps keys to objects, just like a hash table.
thank you both
It's an associative array. It's most likely implemented as a hash table.
If you really care the Core Foundation code is open source and you can download it from Apple. NSDictionary sits on top of CFDictionary.
actually I'm less concerned about how it is implemented and more about when i should use it...
From the Collections Programming Topics for Cocoa document:
definition vs. implementation
A hash table is one (moderately efficient) method of implementing associative arrays.
An NSDictionary is specified to behave like an associative array, but the implementation is opaque. The hidden underlying implementation could, for instance, change depending on the size of the array, phase of the moon, & etc.