- [NSMutableArray removeAllObjects]和 - [NSMutableArray addObject:]抛出NSRangeException

时间:2013-08-02 02:19:55

标签: objective-c nsmutablearray nsrangeexception

第一次崩溃是由对removeAllObjects的调用引起的,第二次是addObject:

2013-08-01 21:54:05.706 Zipper[1754:1803] An uncaught exception was raised
2013-08-01 21:54:05.721 Zipper[1754:1803] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM removeObjectAtIndex:]: index 201 beyond bounds [0 .. 198]'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff94017b06 __exceptionPreprocess + 198
    1   libobjc.A.dylib                     0x00007fff99d043f0 objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff93fb4a04 -[__NSArrayM removeObjectAtIndex:] + 276
    3   CoreFoundation                      0x00007fff93ff457f -[NSMutableArray removeAllObjects] + 79
    4   Zipper                              0x000000010000f760 __21-[JOxxx jo_parse]_block_invoke + 368
    5   libdispatch.dylib                   0x00007fff8fe9af01 _dispatch_call_block_and_release + 15
    6   libdispatch.dylib                   0x00007fff8fe970b6 _dispatch_client_callout + 8
    7   libdispatch.dylib                   0x00007fff8fe9847f _dispatch_queue_drain + 235
    8   libdispatch.dylib                   0x00007fff8fe982f1 _dispatch_queue_invoke + 52
    9   libdispatch.dylib                   0x00007fff8fe981c3 _dispatch_worker_thread2 + 249
10  libsystem_c.dylib                   0x00007fff95f64d0b _pthread_wqthread + 404
    11  libsystem_c.dylib                   0x00007fff95f4f1d1 start_wqthread + 13
)
libc++abi.dylib: terminate called throwing an exception

2013-08-01 21:52:15.964 Zipper[1616:1813] An uncaught exception was raised
2013-08-01 21:52:15.965 Zipper[1616:1813] *** -[__NSArrayM insertObject:atIndex:]: index 132 beyond bounds [0 .. 130]
2013-08-01 21:52:15.966 Zipper[1616:1813] (
    0   CoreFoundation                      0x00007fff94017b06 __exceptionPreprocess + 198
    1   libobjc.A.dylib                     0x00007fff99d043f0 objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff93fc827a -[__NSArrayM insertObject:atIndex:] + 282
    3   Zipper                              0x000000010000f902 __21-[JOxxx jo_parse]_block_invoke + 690
    4   libdispatch.dylib                   0x00007fff8fe9af01 _dispatch_call_block_and_release + 15
    5   libdispatch.dylib                   0x00007fff8fe970b6 _dispatch_client_callout + 8
    6   libdispatch.dylib                   0x00007fff8fe9847f _dispatch_queue_drain + 235
    7   libdispatch.dylib                   0x00007fff8fe982f1 _dispatch_queue_invoke + 52
    8   libdispatch.dylib                   0x00007fff8fe981c3 _dispatch_worker_thread2 + 249
    9   libsystem_c.dylib                   0x00007fff95f64d0b _pthread_wqthread + 404
    10  libsystem_c.dylib                   0x00007fff95f4f1d1 start_wqthread + 13
)

1 个答案:

答案 0 :(得分:0)

两个队列同时访问该阵列。