Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Build a Simple iPhone App with Swift Views and View Controllers View Controllers and IBAction

Ricardo Acuna
Ricardo Acuna
9,014 Points

Clicking the button returns `unrecognized selector sent to instance` and `Terminating app due to uncaught exception`.

On the ViewController @IBAction func showFunFact() { println("You pressed me!") } Instead of printing the answer to the console the following comes out:

2014-09-25 23:48:43.673 FunFacts[26365:364200] -[FunFacts.ViewController showFunFact:]: unrecognized selector sent to instance 0x7fccc8491530
2014-09-25 23:48:43.707 FunFacts[26365:364200] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[FunFacts.ViewController showFunFact:]: unrecognized selector sent to instance 0x7fccc8491530'
*** First throw call stack:
(
    0   CoreFoundation                      0x00000001010b53f5 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x0000000102be3bb7 objc_exception_throw + 45
    2   CoreFoundation                      0x00000001010bc50d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
    3   CoreFoundation                      0x00000001010147fc ___forwarding___ + 988
    4   CoreFoundation                      0x0000000101014398 _CF_forwarding_prep_0 + 120
    5   UIKit                               0x00000001019409ee -[UIApplication sendAction:to:from:forEvent:] + 75
    6   UIKit                               0x0000000101a46bd0 -[UIControl _sendActionsForEvents:withEvent:] + 467
    7   UIKit                               0x0000000101a45f9f -[UIControl touchesEnded:withEvent:] + 522
    8   UIKit                               0x00000001019863b8 -[UIWindow _sendTouchesForEvent:] + 735
    9   UIKit                               0x0000000101986ce3 -[UIWindow sendEvent:] + 683
    10  UIKit                               0x0000000101953ae1 -[UIApplication sendEvent:] + 246
    11  UIKit                               0x0000000101960bad _UIApplicationHandleEventFromQueueEvent + 17370
    12  UIKit                               0x000000010193c233 _UIApplicationHandleEventQueue + 1961
    13  CoreFoundation                      0x0000000100feaad1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    14  CoreFoundation                      0x0000000100fe099d __CFRunLoopDoSources0 + 269
    15  CoreFoundation                      0x0000000100fdffd4 __CFRunLoopRun + 868
    16  CoreFoundation                      0x0000000100fdfa06 CFRunLoopRunSpecific + 470
    17  GraphicsServices                    0x00000001051a49f0 GSEventRunModal + 161
    18  UIKit                               0x000000010193f550 UIApplicationMain + 1282
    19  FunFacts                            0x0000000100ed925e top_level_code + 78
    20  FunFacts                            0x0000000100ed929a main + 42
    21  libdyld.dylib                       0x00000001033bd145 start + 1
    22  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)

1 Answer

The button is probably connected to some other action? Check the outlets of the button to make sure.

Ricardo Acuna
Ricardo Acuna
9,014 Points

I edited the button's title, that's probably why it got unlinked. I fixed it by deleting the button and relinking it to the View Controller. Thanks.

Great!