Swift应用程序开发错误 - 线程1信号SIGABRT

问题描述 投票:0回答:1

我知道这个问题之前已被多次询问,但是使用从他们的答案中获得的所有信息,我的项目仍然崩溃!

我正在学习App Development,在Apple的Everyone Can Code系列中使用Swift的iBook Intro到App Development。我正在使用第17.3章,它是多个动作和出口,我正在完全按照所示的方式跟踪代码和视频,但是,当我轻弹第一个开关时,View对象应该变为红色,但它没有,并且轻弹另外两个开关崩溃应用程序,错误Thread 1: signal SIGABRT。控制台错误是这样的:

2018-09-06 18:29:35.503697+1000 ColorMix[2654:141233] -[ColorMix.ViewController greenSwitch:]: unrecognized selector sent to instance 0x7f89a4c09110
2018-09-06 18:29:35.515103+1000 ColorMix[2654:141233] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ColorMix.ViewController greenSwitch:]: unrecognized selector sent to instance 0x7f89a4c09110'
*** First throw call stack:
(
    0   CoreFoundation                      0x00000001113a81e6 __exceptionPreprocess + 294
    1   libobjc.A.dylib                     0x000000010f9ce031 objc_exception_throw + 48
    2   CoreFoundation                      0x0000000111429784 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
    3   UIKit                               0x0000000111d5e6db -[UIResponder doesNotRecognizeSelector:] + 295
    4   CoreFoundation                      0x000000011132a898 ___forwarding___ + 1432
    5   CoreFoundation                      0x000000011132a278 _CF_forwarding_prep_0 + 120
    6   UIKit                               0x0000000111b313e8 -[UIApplication sendAction:to:from:forEvent:] + 83
    7   UIKit                               0x0000000111cac7a4 -[UIControl sendAction:to:forEvent:] + 67
    8   UIKit                               0x0000000111cacac1 -[UIControl _sendActionsForEvents:withEvent:] + 450
    9   UIKit                               0x00000001127edea0 -[UISwitchModernVisualElement sendStateChangeActions] + 73
    10  UIKit                               0x00000001121af9d3 -[UISwitchMVEGestureTrackingSession _sendStateChangeActionsIfNecessary] + 63
    11  UIKit                               0x00000001127ee62c -[UISwitchModernVisualElement _handleLongPressWithGestureLocationInBounds:gestureState:] + 760
    12  UIKit                               0x000000011212854f -[UIGestureRecognizerTarget _sendActionWithGestureRecognizer:] + 57
    13  UIKit                               0x0000000112131324 _UIGestureRecognizerSendTargetActions + 109
    14  UIKit                               0x000000011212eb6c _UIGestureRecognizerSendActions + 307
    15  UIKit                               0x000000011212ddc0 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 859
    16  UIKit                               0x0000000112112e24 _UIGestureEnvironmentUpdate + 1329
    17  UIKit                               0x00000001121128a7 -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:] + 484
    18  UIKit                               0x00000001121119a9 -[UIGestureEnvironment _updateGesturesForEvent:window:] + 281
    19  UIKit                               0x0000000111ba77ab -[UIWindow sendEvent:] + 4064
    20  UIKit                               0x0000000111b4b310 -[UIApplication sendEvent:] + 352
    21  UIKit                               0x000000011248c6af __dispatchPreprocessedEventFromEventQueue + 2796
    22  UIKit                               0x000000011248f2c4 __handleEventQueueInternal + 5949
    23  CoreFoundation                      0x000000011134abb1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    24  CoreFoundation                      0x000000011132f4af __CFRunLoopDoSources0 + 271
    25  CoreFoundation                      0x000000011132ea6f __CFRunLoopRun + 1263
    26  CoreFoundation                      0x000000011132e30b CFRunLoopRunSpecific + 635
    27  GraphicsServices                    0x0000000115efea73 GSEventRunModal + 62
    28  UIKit                               0x0000000111b30057 UIApplicationMain + 159
    29  ColorMix                            0x000000010f0c2a67 main + 55
    30  libdyld.dylib                       0x00000001147ec955 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

以下是我的ViewController和Main.storyboard文件的屏幕截图:

enter image description here enter image description here

此外,在我的应用程序崩溃之后,发生了一些奇怪的事情:在第33和48行创建了新的出口(填充点),其中没有任何与出口有关的内容。

如果您需要更多信息/代码,请告诉我,我将不胜感激!

ios swift xcode sigabrt
1个回答
2
投票

这个

[ColorMix.ViewController greenSwitch:]:无法识别的选择器发送到实例

意味着你创建了一个名为greenSwitch的IBAction然后将其删除,所以尝试将其从IB中的交换机中删除,或者在VC中创建该动作

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.