数组中相邻的日期元素

发布于 2024-09-26 18:09:08 字数 295 浏览 1 评论 0原文

如何比较包含日期的相邻数组元素。问题是当 我

BOOL day = [[temp_date objectAtIndex:k] compare:[temp_date objectAtIndex:k+1]];

通过以下期望

进行比较* 由于未捕获的异常“NSRangeException”而终止应用程序,原因:“* -[NSCFArray objectAtIndex:]:索引(23)超出界限(23)”

提前致谢

问候, 萨蒂什

how to compare an adjacent array element that contains date. The thing is when
i compare

BOOL day = [[temp_date objectAtIndex:k] compare:[temp_date objectAtIndex:k+1]];

it throughs the following expection

* Terminating app due to uncaught exception 'NSRangeException', reason: '* -[NSCFArray objectAtIndex:]: index (23) beyond bounds (23)'

thanks in advance

Regards,
sathish

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

最丧也最甜 2024-10-03 18:09:08

看来你做的一切都是正确的,只需检查你是否始终在数组的范围内。如果您在循环中执行此操作,则条件可能是:

for (int k = 0; k+1 <temp_date.count; ++k)
   ...

It seems you do everything correct, just check that you're always within array's bounds. If you do that in a loop the condition may be:

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