Reputation: 44087
I know this question has been asked multiple times before, but using all the information gained from their answers, my project still crashes!
I am learning App Development, using the iBook Intro to App Development with Swift, in Apple's Everyone Can Code series. I am using Chapter 17.3, which is Multiple Actions and Outlets, and I am following the code and videos exactly as shown, however, when I flick the first switch, the View object should turn red, but it doesn't, and flicking the two other switches crashes the app, with the error Thread 1: signal SIGABRT
. The console error is this:
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)
Here are screenshots of my ViewController and Main.storyboard files:
Also, after my app crashes, something weird happens: new outlets (filled dots) are created on lines 33 & 48, where there is nothing relating to outlets whatsoever.
Please let me know if you need any more information/code, I would appreciate all help!
Upvotes: 0
Views: 349
Reputation: 100503
This
[ColorMix.ViewController greenSwitch:]: unrecognized selector sent to instance
means that you have created an IBAction named greenSwitch
then deleted it , so try to remove it from the switch in IB , or create that action inside the VC
Upvotes: 2