什么是最有效的方式来排序NSSet?

编程入门 行业动态 更新时间:2024-10-10 03:28:45
本文介绍了什么是最有效的方式来排序NSSet?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

基于对象的属性,在 NSSet / NSMutableSet 中排序对象的最有效方法是什么集合?现在我的方式是通过迭代每个对象,将它们添加到 NSMutableArray ,并排序该数组与 NSSortDescriptor 。

What's the most efficient way to sort objects in an NSSet/NSMutableSet based on a property of the objects in the set? Right now the way I am doing it is by iterating through each object, add them to a NSMutableArray, and sort that array with NSSortDescriptor.

推荐答案

尝试使用

[[mySet allObjects] sortedArrayUsingDescriptors:descriptors];

编辑:对于iOS≥4.0和Mac OS X≥10.6,直接使用

Edit: For iOS ≥ 4.0 and Mac OS X ≥ 10.6 you can directly use

[mySet sortedArrayUsingDescriptors:descriptors];

更多推荐

什么是最有效的方式来排序NSSet?

本文发布于:2023-11-30 09:51:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1649558.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:最有效   方式   NSSet

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!