objective-c - 应用程序在选项卡单击时崩溃消息类似于 Collection <CALayerArray : > was mutated while being enumerated

标签 objective-c ios

您能找出我的应用程序崩溃的原因吗?当我点击选项卡栏中的任何选项卡时,应用程序崩溃。这是一个随机问题,但生成非常频繁。错误信息如下:

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];
}];

检查你的代码是否在做类似的事情。

关于objective-c - 应用程序在选项卡单击时崩溃消息类似于 Collection <CALayerArray : > was mutated while being enumerated,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8907878/

相关文章:

ios - iOS SDK 中的 Youtube 集成

ios - 在使用 SFRestAPI 时一起使用部分和 tableviewcells 时出错

ios - 如何自动调整包含多行 UIButton 的 UITableViewCell 的高度?

objective-c - 拆除 UIViewController 时是否总是调用 viewDidUnload 和 dealloc?

iphone - 使用 Objective-C 类避免编译错误

ios - 跟踪用户当前位置后的 Google map myLocation 按钮颜色 - ios

ios - 选择一个角色 - Swift/SpriteKit

objective-c - 将自定义 ViewController 分配为窗口的 rootViewController

objective-c - 如果@protected 是默认值,为什么这个ivar 需要@protected?

ios - 如何关闭操作表中显示的 UIPicker?