NSMutableArray 对对象进行排序
可能的重复:
如何对其中包含自定义对象的 NSMutableArray 进行排序?< /a>
我有一个类型为 NSObject 的对象,其中包含 NSMutableArray 的“posts”对象类型。该帖子对象具有 ID 属性。
MyObject.posts.post.ID = NSInteger;
我想按 ID 对“帖子”NSMutableArray 进行排序。我尝试了几种方法但未能成功。 任何帮助/示例都会很棒。
谢谢。
Possible Duplicate:
How to sort an NSMutableArray with custom objects in it?
i have a object with Type of NSObject contains "posts" object type of NSMutableArray. that post object has ID property.
MyObject.posts.post.ID = NSInteger;
I want to sort "posts" NSMutableArray by ID. i have tried couple ways but couldn't be success.
any help/sample would be great.
thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以实现比较方法,或使用 NSSortDescriptor。
这个问题和答案可能对你有帮助。
如何对其中包含自定义对象的 NSMutableArray 进行排序?< /a>
You can implement a compare method, or use NSSortDescriptor.
This question and the answer may helps you.
How to sort an NSMutableArray with custom objects in it?
您可以使用
NSComparator
对带有块的数组进行排序(NSComparator)-sortedArrayUsingComparator 的定义:找到 此处
You can sort an array with a block using
NSComparator
(NSComparator)Definition of -sortedArrayUsingComparator: found here