문제

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top