由于未捕获的异常,如何处理终止应用程序

时间:2015-02-24 13:05:55

标签: ios objective-c xcode

没有理解应用程序崩溃随机时间的原因。无法找到任何str。请帮助..我无法通过此日志跟踪问题。还请帮助我如何处理这样困难的日志,以追踪问题的确切位置。

Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <__NSSetM: 0x7fda3c871090> was mutated while being enumerated.'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000105ed1f35 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x0000000104ce1bb7 objc_exception_throw + 45
    2   CoreFoundation                      0x0000000105ed1894 __NSFastEnumerationMutationHandler + 132
    3   Foundation                          0x000000010488e3be -[NSISEngine _coreReplaceMarker:withMarkerPlusDelta:] + 347
    4   Foundation                          0x000000010488e1dc -[NSISEngine constraintDidChangeSuchThatMarker:shouldBeReplacedByMarkerPlusDelta:] + 239
    5   Foundation                          0x000000010488adea -[NSLayoutConstraint _containerGeometryDidChange] + 310
    6   UIKit                               0x0000000103c03a04 ___UITagLayoutConstraintsForConstantChangeForSelectedAttributes_block_invoke + 409
    7   UIKit                               0x0000000103c1027b -[UIView(AdditionalLayoutSupport) _withUnsatisfiableConstraintsLoggingSuspendedIfEngineDelegateExists:] + 115
    8   UIKit                               0x0000000103c03865 _UITagLayoutConstraintsForConstantChangeForSelectedAttributes + 80
    9   UIKit                               0x00000001035ea079 -[UIView _layoutMarginsDidChange] + 60
    10  UIKit                               0x00000001035ea248 -[UIView setLayoutMargins:] + 426
    11  UIKit                               0x00000001036a9296 -[UIViewController _setContentOverlayInsets:] + 270
    12  UIKit                               0x00000001036a9bc7 -[UIViewController _updateContentOverlayInsetsFromParentIfNecessary] + 1857
    13  UIKit                               0x00000001036038cd -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
    14  QuartzCore                          0x0000000109d9dde8 -[CALayer layoutSublayers] + 150
    15  QuartzCore                          0x0000000109d92a0e _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
    16  QuartzCore                          0x0000000109d9287e _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
    17  QuartzCore                          0x0000000109d0063e _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242
    18  QuartzCore                          0x0000000109d0174a _ZN2CA11Transaction6commitEv + 390
    19  UIKit                               0x000000010358714d _UIApplicationHandleEventQueue + 2035
    20  CoreFoundation                      0x0000000105e07551 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    21  CoreFoundation                      0x0000000105dfd41d __CFRunLoopDoSources0 + 269
    22  CoreFoundation                      0x0000000105dfca54 __CFRunLoopRun + 868
    23  CoreFoundation                      0x0000000105dfc486 CFRunLoopRunSpecific + 470
    24  GraphicsServices                    0x0000000107a659f0 GSEventRunModal + 161
    25  UIKit                               0x000000010358a420 UIApplicationMain + 1282
    26  HomeDiary                           0x0000000102c861c3 main + 115
    27  libdyld.dylib                       0x0000000106fa5145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) bt
* thread #1: tid = 0x1f5db, 0x00000001072c3286 libsystem_kernel.dylib`__pthread_kill + 10, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x00000001072c3286 libsystem_kernel.dylib`__pthread_kill + 10
    frame #1: 0x00000001072f642f libsystem_pthread.dylib`pthread_kill + 90
    frame #2: 0x000000010705319a libsystem_sim_c.dylib`abort + 129
    frame #3: 0x0000000106e14481 libc++abi.dylib`abort_message + 257
    frame #4: 0x0000000106e3c3d5 libc++abi.dylib`default_terminate_handler() + 267
    frame #5: 0x0000000104ce1e19 libobjc.A.dylib`_objc_terminate() + 103
    frame #6: 0x0000000106e39b01 libc++abi.dylib`std::__terminate(void (*)()) + 8
    frame #7: 0x0000000106e397aa libc++abi.dylib`__cxa_rethrow + 99
    frame #8: 0x0000000104ce1d2c libobjc.A.dylib`objc_exception_rethrow + 40
    frame #9: 0x0000000105dfc53e CoreFoundation`CFRunLoopRunSpecific + 654
    frame #10: 0x0000000107a659f0 GraphicsServices`GSEventRunModal + 161
    frame #11: 0x000000010358a420 UIKit`UIApplicationMain + 1282
  * frame #12: 0x0000000102c861c3 HomeDiary`main(argc=1, argv=0x00007fff5cf8e348) + 115 at main.m:16
    frame #13: 0x0000000106fa5145 libdyld.dylib`start + 1

1 个答案:

答案 0 :(得分:2)

崩溃的原因在第一行...... Collection <__NSSetM: 0x7fda3c871090> was mutated while being enumerated.

这意味着您有一个NSMutableSet并且您要枚举它for (id someObject in mySet) {}[mySet enumerateObjects...,并且在该枚举中您正在改变该集。

像这样......

for (id someObject in mySet) {
    [mySet removeObject:someObject];
}

或类似的东西。你不能这样做,它会崩溃......因此你的崩溃。

要查找发生这种情况的位置,您需要向项目添加异常断点。然后,这将停止执行导致崩溃的代码行。