I try to compile a simple application with one button and output, when clicked, its values ​​to the log, here is the code:

import UIKit class ViewController: UIViewController { @IBAction func TouchDigit(_ sender: UIButton) { let digit = sender.currentTitle print("\(digit) was be called") } } 

But to my regret, such a whole log of errors arrives:

 2017-10-12 17:41:23.972 CalculatorStanford[27870:11130726] -[CalculatorStanford.ViewController Button:]: unrecognized selector sent to instance 0x7f99fed07ac0 2017-10-12 17:41:23.980 CalculatorStanford[27870:11130726] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CalculatorStanford.ViewController Button:]: unrecognized selector sent to instance 0x7f99fed07ac0' *** First throw call stack: ( 0 CoreFoundation 0x0000000111275b0b __exceptionPreprocess + 171 1 libobjc.A.dylib 0x000000010e51b141 objc_exception_throw + 48 2 CoreFoundation 0x00000001112e5134 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132 3 CoreFoundation 0x00000001111fc840 ___forwarding___ + 1024 4 CoreFoundation 0x00000001111fc3b8 _CF_forwarding_prep_0 + 120 5 UIKit 0x000000010e9eed82 -[UIApplication sendAction:to:from:forEvent:] + 83 6 UIKit 0x000000010eb735ac -[UIControl sendAction:to:forEvent:] + 67 7 UIKit 0x000000010eb738c7 -[UIControl _sendActionsForEvents:withEvent:] + 450 8 UIKit 0x000000010eb72802 -[UIControl touchesEnded:withEvent:] + 618 9 UIKit 0x000000010ea5c7ea -[UIWindow _sendTouchesForEvent:] + 2707 10 UIKit 0x000000010ea5df00 -[UIWindow sendEvent:] + 4114 11 UIKit 0x000000010ea0aa84 -[UIApplication sendEvent:] + 352 12 UIKit 0x000000010f1ee5d4 __dispatchPreprocessedEventFromEventQueue + 2926 13 UIKit 0x000000010f1e6532 __handleEventQueue + 1122 14 CoreFoundation 0x000000011121bc01 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 15 CoreFoundation 0x00000001112010cf __CFRunLoopDoSources0 + 527 16 CoreFoundation 0x00000001112005ff __CFRunLoopRun + 911 17 CoreFoundation 0x0000000111200016 CFRunLoopRunSpecific + 406 18 GraphicsServices 0x0000000113180a24 GSEventRunModal + 62 19 UIKit 0x000000010e9ed134 UIApplicationMain + 159 20 CalculatorStanford 0x000000010df44b57 main + 55 21 libdyld.dylib 0x000000011221565d start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb) 

I am learning to do this on courses at Oxford University, but for some reason there are no such mistakes there. What could be the problem?

    1 answer 1

    check out the outlet in the storyboard (your button calls the method which is not in the controller, maybe you changed the name of the method or something like that)

    your code should have this: enter image description here

    • In the code, I impose on the point and it highlights the button, I understand that they are connected by one method - NTP
    • look at the second screen - Andrey Iskamov
    • and try to remove the link and reconnect - Andrey Iskamov
    • I am eternally grateful to you. I have a slightly different look, maybe another version of xcode (not updated yet). It was in the Sent Events, but after the new connection, it all worked. - NTP