对 NSDate 进行排序,然后将其与其原始唯一 ID 相关联

发布于 2024-11-19 14:14:02 字数 230 浏览 12 评论 0原文

我有两个数组,一个由 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鸠魁 2024-11-26 14:14:02

你不能将两个数组关联到一个 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文