对 NSDate 进行排序,然后将其与其原始唯一 ID 相关联
我有两个数组,一个由 NSDates 组成,另一个由我用作唯一标识符的整数组成。
我使用 sortedArrayUsingSelector:@selector(compare:)
对 NSDate 数组进行排序,这对它们进行了完美的排序,问题是我需要将这些日期关联回它们的原始 UID(另一个 NSArray)。
有没有一种简单的方法可以做到这一点,或者我必须做一些 for/if 语句?
I have two arrays, one that is made up of NSDates and one that's made up of ints that I use as a unique identifier.
I sort the NSDate array using sortedArrayUsingSelector:@selector(compare:)
which sorts them perfectly, the problem is I need to associate those dates back to their original UID (the other NSArray).
Is there a simple way to do this or do I have to do some for/if statements?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你不能将两个数组关联到一个 NSDictionary 中吗?然后你就可以按照你想要的方式对它们进行排序。
Couldn't you associate the two arrays in one NSDictionary? It would then be ok for you to sort them the way you want.