Getting an error when adding item, Chapter 13

Hi - I’m getting an error when clicking on ‘done’ after adding an item. I have tried comparing the code with the downloaded project, but it says it is the same. The segue identifier is named on the storyboard, and I’m really stuck and would appreciate any help please. My project is at:

The error I’m getting is:
2019-08-30 09:10:00.242449+0100 Checklists[3101:116486] -[Checklists.AddItemViewController done:]: unrecognized selector sent to instance 0x7fbc5af06740
2019-08-30 09:10:00.313611+0100 Checklists[3101:116486] *** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[Checklists.AddItemViewController done:]: unrecognized selector sent to instance 0x7fbc5af06740’
*** First throw call stack:
(
0 CoreFoundation 0x000000010e00d6fb __exceptionPreprocess + 331
1 libobjc.A.dylib 0x000000010c087ac5 objc_exception_throw + 48
2 CoreFoundation 0x000000010e02bab4 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 UIKitCore 0x00000001103fcc3d -[UIResponder doesNotRecognizeSelector:] + 287
4 CoreFoundation 0x000000010e012443 forwarding + 1443
5 CoreFoundation 0x000000010e014238 _CF_forwarding_prep_0 + 120
6 UIKitCore 0x00000001103d2204 -[UIApplication sendAction:to:from:forEvent:] + 83
7 UIKitCore 0x000000010fb3c963 __45-[_UIButtonBarTargetAction _invoke:forEvent:]_block_invoke + 154
8 UIKitCore 0x000000010fb3c89c -[_UIButtonBarTargetAction _invoke:forEvent:] + 152
9 UIKitCore 0x00000001103d2204 -[UIApplication sendAction:to:from:forEvent:] + 83
10 UIKitCore 0x000000010fe27c19 -[UIControl sendAction:to:forEvent:] + 67
11 UIKitCore 0x000000010fe27f36 -[UIControl _sendActionsForEvents:withEvent:] + 450
12 UIKitCore 0x000000010fe26eec -[UIControl touchesEnded:withEvent:] + 583
13 UIKitCore 0x000000011040aeee -[UIWindow _sendTouchesForEvent:] + 2547
14 UIKitCore 0x000000011040c5d2 -[UIWindow sendEvent:] + 4079
15 UIKitCore 0x00000001103ead16 -[UIApplication sendEvent:] + 356
16 UIKitCore 0x00000001104bb293 __dispatchPreprocessedEventFromEventQueue + 3232
17 UIKitCore 0x00000001104bdbb9 __handleEventQueueInternal + 5911
18 CoreFoundation 0x000000010df74be1 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17
19 CoreFoundation 0x000000010df74463 __CFRunLoopDoSources0 + 243
20 CoreFoundation 0x000000010df6eb1f __CFRunLoopRun + 1231
21 CoreFoundation 0x000000010df6e302 CFRunLoopRunSpecific + 626
22 GraphicsServices 0x0000000115b522fe GSEventRunModal + 65
23 UIKitCore 0x00000001103d0ba2 UIApplicationMain + 140
24 Checklists 0x000000010b79dcfb main + 75
25 libdyld.dylib 0x000000010ef41541 start + 1
26 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Thank you

It is something about the connection of the doneBarButton to the done() action.

Does the cancel button work? Your declarations of these two actions are different:

    @IBAction func cancel(_ sender: UIBarButtonItem) {
    
    @IBAction func done() {

You might try making the done one

    @IBAction func done(_ sender: UIBarButtonItem) {

Or just remove the action link on the storyboard, and then redo it. Storyboards are one place where it is harder to compare your version and the tutorial version.

Thanks - I eventually found the wrong connection and it now works!

This topic was automatically closed after 166 days. New replies are no longer allowed.