【问题标题】:NSRangeException with NSArray objectAtIndex, index beyond boundsNSRangeException 与 NSArray objectAtIndex,索引超出范围
【发布时间】:2010-06-05 06:39:32
【问题描述】:

谁能告诉我以下错误在 iOS Objective-C 中的含义:

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

【问题讨论】:

    标签: ios crash runtime-error


    【解决方案1】:

    这意味着您的索引不在数组的有效范围内。您的数组有 13 个元素,您正在尝试访问第 14 个元素。在 C 中,索引从 0 开始,因此数组的有效索引从 0 到长度 - 1。

    这通常是由off by one error 引起的。

    【讨论】:

    • 非常感谢杰森....我解决了我的问题....你是对的,我正在尝试访问第 14 个元素,非常感谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多