gpt4 book ai didi

ios - EXC_BAD_INSTRUCTION 按下按钮

转载 作者:搜寻专家 更新时间:2023-11-01 06:23:44 26 4
gpt4 key购买 nike

我是 Swift 的新手,目前正在尝试学习它,但我遇到了一个神秘的问题。正如您在下图中看到的,有一些控件已正确链接到此 View Controller ,在按下 UI 中的按钮后,我们将执行下面的代码,但我总是得到一个 EXC_BAD_INSTRUCTION。我不明白为什么!!

enter image description here

这是堆栈跟踪中的一些信息。

(lldb) thread info
thread #1: tid = 0x9319, 0x0006c5d5 App`App.AViewController.sendCommentViaEmail (self=<unavailable>)() -> () + 9349 at AViewController.swift:49, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)

(lldb) frame select 1
frame #1: 0x037067cd libobjc.A.dylib`-[NSObject performSelector:withObject:withObject:] + 84
libobjc.A.dylib`-[NSObject performSelector:withObject:withObject:] + 84:
-> 0x37067cd: addl $0x1c, %esp
0x37067d0: popl %esi
0x37067d1: popl %edi
0x37067d2: popl %ebx

编辑:

下面的堆栈跟踪

* thread #1: tid = 0x1e19, 0x0005a5d5 A`A.AViewController.sendCommentViaEmail (self=<unavailable>)() -> () + 9349 at AViewController.swift:49, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
* frame #0: 0x0005a5d5 A`A.AViewController.sendCommentViaEmail (self=<unavailable>)() -> () + 9349 at AViewController.swift:49
frame #1: 0x036f47cd libobjc.A.dylib`-[NSObject performSelector:withObject:withObject:] + 84
frame #2: 0x01ea323d UIKit`-[UIApplication sendAction:to:from:forEvent:] + 99
frame #3: 0x02213840 UIKit`-[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 139
frame #4: 0x036f47cd libobjc.A.dylib`-[NSObject performSelector:withObject:withObject:] + 84
frame #5: 0x01ea323d UIKit`-[UIApplication sendAction:to:from:forEvent:] + 99
frame #6: 0x01ea31cf UIKit`-[UIApplication sendAction:toTarget:fromSender:forEvent:] + 64
frame #7: 0x01fd6e86 UIKit`-[UIControl sendAction:to:forEvent:] + 69
frame #8: 0x01fd72a3 UIKit`-[UIControl _sendActionsForEvents:withEvent:] + 598
frame #9: 0x01fd650d UIKit`-[UIControl touchesEnded:withEvent:] + 660
frame #10: 0x01ef360a UIKit`-[UIWindow _sendTouchesForEvent:] + 874
frame #11: 0x01ef40e5 UIKit`-[UIWindow sendEvent:] + 791
frame #12: 0x01eb9549 UIKit`-[UIApplication sendEvent:] + 242
frame #13: 0x01ec937e UIKit`_UIApplicationHandleEventFromQueueEvent + 20690
frame #14: 0x01e9db19 UIKit`_UIApplicationHandleEventQueue + 2206
frame #15: 0x039791df CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
frame #16: 0x0396eced CoreFoundation`__CFRunLoopDoSources0 + 253
frame #17: 0x0396e248 CoreFoundation`__CFRunLoopRun + 952
frame #18: 0x0396dbcb CoreFoundation`CFRunLoopRunSpecific + 443
frame #19: 0x0396d9fb CoreFoundation`CFRunLoopRunInMode + 123
frame #20: 0x085dc24f GraphicsServices`GSEventRunModal + 192
frame #21: 0x085dc08c GraphicsServices`GSEventRun + 104
frame #22: 0x01ea18b6 UIKit`UIApplicationMain + 1526
frame #23: 0x000919cc A`main(argc=1, argv=0xbffaa62c) + 76 at main.m:12
frame #24: 0x04490ac9 libdyld.dylib`start + 1

以下是我正在使用的属性:无论它们是否链接到 UI,我都会得到相同的结果。

Properties linked to the UI controls and same result

最佳答案

emailToMyselfSwitch 从哪里来?如果它是一个 IBOutlet,那么您似乎忘记了将它从 IB 连接到您的代码。如果不是这种情况,请显示更多上下文。

关于ios - EXC_BAD_INSTRUCTION 按下按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28397181/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com