[__NSArrayM objectAtIndex:]:索引2超出空数组的边界'

时间:2014-06-04 11:50:46

标签: ios objective-c

我遇到了这次崩溃。这是我的崩溃原因。我不明白我在做什么。

 reason: '*** -[__NSArrayM objectAtIndex:]: index 2 beyond bounds for empty array'
    *** First throw call stack:
    (
        0   CoreFoundation                      0x036131e4 __exceptionPreprocess + 180
        1   libobjc.A.dylib                     0x02c1c8e5 objc_exception_throw + 44
        2   CoreFoundation                      0x035b43f6 -[__NSArrayM objectAtIndex:] + 246
        3   Stampd                              0x0007e928 -[VenueProfile tableView:cellForRowAtIndexPath:] + 472
        4   UIKit                               0x017c811f -[UITableView _createPreparedCellForGlobalRow:withIndexPath:] + 412
        5   UIKit                               0x017c81f3 -[UITableView _createPreparedCellForGlobalRow:] + 69
        6   UIKit                               0x017a9ece -[UITableView _updateVisibleCellsNow:] + 2428
        7   UIKit                               0x017be6a5 -[UITableView layoutSubviews] + 213
        8   UIKit                               0x0173e964 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
        9   libobjc.A.dylib                     0x02c2e82b -[NSObject performSelector:withObject:] + 70
        10  QuartzCore                          0x0055945a -[CALayer layoutSublayers] + 148
        11  QuartzCore                          0x0054d244 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
        12  QuartzCore                          0x0054d0b0 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
        13  QuartzCore                          0x004b37fa _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
        14  QuartzCore                          0x004b4b85 _ZN2CA11Transaction6commitEv + 393
        15  QuartzCore                          0x00581cc6 _ZN2CA7Display11DisplayLink14dispatch_itemsEyyy + 474
        16  QuartzCore                          0x00582147 _ZN2CA7Display16TimerDisplayLink8callbackEP16__CFRunLoopTimerPv + 123
        17  CoreFoundation                      0x035d1ac6 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 22
        18  CoreFoundation                      0x035d14ad __CFRunLoopDoTimer + 1181
        19  CoreFoundation                      0x035b9538 __CFRunLoopRun + 1816
        20  CoreFoundation                      0x035b89d3 CFRunLoopRunSpecific + 467
        21  CoreFoundation                      0x035b87eb CFRunLoopRunInMode + 123
        22  GraphicsServices                    0x03bdb5ee GSEventRunModal + 192
        23  GraphicsServices                    0x03bdb42b GSEventRun + 104
        24  UIKit                               0x016cff9b UIApplicationMain + 1225
        25  Stampd                              0x000044e2 main + 130
        26  libdyld.dylib                       0x0431d701 start + 1
    )
    libc++abi.dylib: terminating with uncaught exception of type NSException

2 个答案:

答案 0 :(得分:1)

错误

  

[__ NSArrayM objectAtIndex:]:索引2超出空数组的界限

明确指出,试图访问空数组。检查数组为alloc& init并在其中包含对象

答案 1 :(得分:0)

将数组放在NSLog中,方法是numberOfRowsInSection。这将为您提供数组中的对象,如果数组为空,请检查您是否正确初始化数组。如果没有,请在向其中添加对象之前分配并初始化数组。