从完成块发送消息会导致EXC_BAD_ACCESS

时间:2014-10-20 23:57:05

标签: objective-c objective-c-blocks uialertcontroller

为了解决UIAlertView的向后兼容性,我提出了一个似乎适用于iOS 8及更低版本的界面。

除此之外,我还有很少的课程负责在应用程序启动后管理空闲计时器。完成大约30分钟的空闲时间后,会向用户显示警报。

根据用户操作,调用app delegate中定义的适当方法。

Here是要点的链接

link到github项目本身

在SPTimer.m内你会注意到#34; - (void)showIdleAlert"正在引发崩溃。

我已将NSZombieEnabled设置为YES。然而,没有适当的呼叫追踪。

跑步''在调试器内部可以看到以下错误。

* thread #1: tid = 0x2c301d, 0x0000000101884017 libobjc.A.dylib`objc_msgSend + 23, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x18080100)
    frame #0: 0x0000000101884017 libobjc.A.dylib`objc_msgSend + 23
  * frame #1: 0x000000010133459c SessionTimer`__32-[UIAlertMode initAlertWith::::]_block_invoke10(.block_descriptor=0x00007f8fe2765280, action=0x00007f8fe2769c90) + 76 at UIAlertMode.m:55
    frame #2: 0x0000000102216097 UIKit`-[UIAlertController _fireOffActionOnTargetIfValidForAction:] + 55
    frame #3: 0x00000001022165d9 UIKit`__85-[UIAlertController _dismissAnimated:triggeringAction:triggeredByPopoverDimmingView:]_block_invoke + 30
    frame #4: 0x00000001020c179c UIKit`-[UIPresentationController transitionDidFinish:] + 1118
    frame #5: 0x00000001020c3b17 UIKit`__56-[UIPresentationController runTransitionForCurrentState]_block_invoke_2 + 133
    frame #6: 0x0000000102711ac3 UIKit`-[_UIViewControllerTransitionContext completeTransition:] + 110
    frame #7: 0x00000001020319f3 UIKit`-[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 326
    frame #8: 0x0000000102019d9a UIKit`-[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 209
    frame #9: 0x000000010201a0d0 UIKit`-[UIViewAnimationState animationDidStop:finished:] + 76
    frame #10: 0x00000001058a499e QuartzCore`CA::Layer::run_animation_callbacks(void*) + 308
    frame #11: 0x00000001041177f4 libdispatch.dylib`_dispatch_client_callout + 8
    frame #12: 0x0000000104100991 libdispatch.dylib`_dispatch_main_queue_callback_4CF + 956
    frame #13: 0x0000000101b3c569 CoreFoundation`__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
    frame #14: 0x0000000101aff46b CoreFoundation`__CFRunLoopRun + 2043
    frame #15: 0x0000000101afea06 CoreFoundation`CFRunLoopRunSpecific + 470
    frame #16: 0x000000010519c9f0 GraphicsServices`GSEventRunModal + 161
    frame #17: 0x0000000101fc0550 UIKit`UIApplicationMain + 1282
    frame #18: 0x0000000101333e63 SessionTimer`main(argc=1, argv=0x00007fff5e8cf2c8) + 115 at main.m:14
    frame #19: 0x000000010414c145 libdyld.dylib`start + 1

我承认我的设计并不好,我可能会在这里做一些根本错误的事情。希望得到反馈。

1 个答案:

答案 0 :(得分:3)

显然我将我的块作为assign属性引用而不是copy因此崩溃。以下是对已回复EXC_BAD_ACCESS on customised blocks的原始帖子的引用。

由于