Sort NSDictionary

六月ゝ 毕业季﹏ 提交于 2019-12-02 08:01:42
Laurent Cerveau

You can access the keys in a sorted order with method like keysSortedByValueUsingComparator, keysSortedByValueWithOptions or keysSortedByValueUsingSelector. But by definition a NSDictionary itself has no notion or order.

You can't sort an NSDictionary. If you want , you could create an object to hold the key and value in it, then add to an array and use a sort descriptor to sort on the key field.

NSDictionary is not an ordered collection, however you can sort its keys using comparators like keysSortedByValueUsingComparator, keysSortedByValueUsingSelector.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!