Naturally, the keys of a NSDictionary
are not ordered, and so are its values.
So, why do the allKeys
and allValues
methods of NSDictionary
return NSArray
and not NSSet
?
A value can occur more than once in a dictionary but not in a set. So returning an array returns all the values, while returning a set would return only the unique values.
Keys of course must be unique, so I'd suggest the choice of array rather than set is simple consistency.