Why doesn’t [NSDictionary allKeys] return a set?

前端 未结 5 1120
南笙
南笙 2021-02-12 16:10

Is there a reason for NSDictionary to return its keys as NSArray instead of NSSet? The documentation already states that the order of the

5条回答
  •  旧时难觅i
    2021-02-12 16:36

    Sets tend to be somewhat neglected in API design. They'll be included most of the time, but usually long after all the other standard data structures. Add on top of that the fact that besides the very recent NSFastEnumeration, there is no general collection or sequence protocol in Objective-C — every collection class is completely independent of all the others — and it becomes very hard to switch to sets after an API has already been written that returns arrays.

提交回复
热议问题