Is there a reason for NSDictionary
to return its keys as NSArray
instead of NSSet
? The documentation already states that the order of the
My guess is that Apple is using NSArray
all over the place (and most programmers as well), so this choice comes naturally - and changing it now would come at a high cost. And if using arrays internally, a copy of an immutable array is much cheaper than building a set just for the sake of mathematical elegance.
Also note that NSSet
and NSArray
don't have a common parent (well, except NSObject
, of course), so abstracting this interface is also impossible (except for returning something that conforms to NSFastEnumeration
).
Just wild speculation, of course. ;-)