NSRangeException 与 NSArray objectAtIndex,索引超出范围
谁能告诉我以下错误在 iOS Objective-C 中意味着什么:
Terminating app due to uncaught exception 'NSRangeException', reason: '-[NSCFArray objectAtIndex:]: index (13) beyond bounds (13)'
Can anyone let me know what the following error means in iOS Objective-C:
Terminating app due to uncaught exception 'NSRangeException', reason: '-[NSCFArray objectAtIndex:]: index (13) beyond bounds (13)'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这意味着您的索引不在数组的有效范围内。您的数组有 13 个元素,您正在尝试访问第 14 个元素。在 C 中,索引从 0 开始,因此数组的索引从 0 到 length - 1 有效。
这通常是由 因一个错误而关闭。
It means that your index is not within the valid range for your array. Your array has 13 elements and you are trying to access the 14th element. In C, indexes start at 0, so arrays have indexes that are valid from 0 to length - 1.
This is typically caused by an off by one error.