选项卡单击消息时应用程序崩溃类似于集合<CALayerArray:>在枚举时发生了突变



你能找出我的应用程序崩溃的原因吗?当我点击我的选项卡中的任何选项卡时,应用程序崩溃。这是一个很低的问题,但产生的频率很高。错误消息如下:

2012-01-18 14:48:50.029 MyApp[2823:f803] *** Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <CALayerArray: 0x6b46bd0> was mutated while being enumerated.'
    *** First throw call stack:
    (0x17a8052 0x1d5cd0a 0x17a7c21 0x66b65f 0x66b80d 0x66b80d 0x66b80d 0x66b80d 0x66bb90 0x66bcb6 0x670a4f 0x66a72b 0x6d8116 0x6d7b0e 0x714dc6 0x7149bd 0x712f8a 0x712e2f 0x7148f4 0x17a9ec9 0x6365c2 0x63655a 0x85b569 0x17a9ec9 0x6365c2 0x63655a 0x6dbb76 0x6dc03f 0x6dbbab 0x85dd1f 0x17a9ec9 0x6365c2 0x63655a 0x6dbb76 0x6dc03f 0x6db2fe 0x65ba30 0x65bc56 0x642384 0x635aa9 0x226afa9 0x177c1c5 0x16e1022 0x16df90a 0x16dedb4 0x16deccb 0x2269879 0x226993e 0x633a9b 0x2a7d 0x29f5)
    terminate called throwing an exception(gdb) bt
    #0  0x9a09e9c6 in __pthread_kill ()
    #1  0x90b50f78 in pthread_kill ()
    #2  0x90b41bdd in abort ()
    #3  0x01f00e78 in abort_message ()
    #4  0x01efe89e in default_terminate ()
    #5  0x01d5cf4b in _objc_terminate ()
    #6  0x01efe8de in safe_handler_caller ()
    #7  0x01efe946 in std::terminate ()
    #8  0x01effb3e in __cxa_rethrow ()
    #9  0x01d5ce49 in objc_exception_rethrow ()
    #10 0x016dee10 in CFRunLoopRunSpecific ()
    #11 0x016deccb in CFRunLoopRunInMode ()
    #12 0x02269879 in GSEventRunModal ()
    #13 0x0226993e in GSEventRun ()
    #14 0x00633a9b in UIApplicationMain ()
    #15 0x00002a7d in main (argc=1, argv=0xbffff5d4) at /Users/Bob/Desktop/MyApp/MyApp/main.m:14
    Current language:  auto; currently objective-c
    (gdb)

通常这是由于在枚举NSMutableArray时添加/删除对象所引起的。例如:

[array enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
  [array removeObject:obj];
}];

检查您的代码是否正在执行类似的操作。

最新更新