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 trialnathantopolanski
4,138 PointsFunFact app redirecting to AppDelegate when button is pressed
I did everything like in the video and I made sure that no other connections were built simultaneously with the button. However, when I press it, instead of showing "another interesting fact", the simulator stops running and redirects me to the AppDelegate. Two things happen :
first : the declaration line : "AppDelegate: UIResponder, UIApplicationDelegate {" highlights in green with the message "Thread 1: signal SIGABRT".
second : the console displays the following message :
2015-04-14 22:42:28.871 ff[54041:1282449] -[ff.ViewController showFunFact:]: unrecognized selector sent to instance 0x787e4b40 2015-04-14 22:42:28.876 ff[54041:1282449] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ff.ViewController showFunFact:]: unrecognized selector sent to instance 0x787e4b40' *** First throw call stack: ( 0 CoreFoundation 0x00267466 exceptionPreprocess + 182 1 libobjc.A.dylib 0x01c56a97 objc_exception_throw + 44 2 CoreFoundation 0x0026f2c5 -[NSObject(NSObject) doesNotRecognizeSelector:] + 277 3 CoreFoundation 0x001b7bc7 ___forwarding_ + 1047 4 CoreFoundation 0x001b778e CF_forwarding_prep_0 + 14 5 libobjc.A.dylib 0x01c6c7cd -[NSObject performSelector:withObject:withObject:] + 84 6 UIKit 0x00a82340 -[UIApplication sendAction:to:from:forEvent:] + 99 7 UIKit 0x00a822d2 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 64 8 UIKit 0x00bb6a56 -[UIControl sendAction:to:forEvent:] + 69 9 UIKit 0x00bb6e73 -[UIControl _sendActionsForEvents:withEvent:] + 598 10 UIKit 0x00bb60dd -[UIControl touchesEnded:withEvent:] + 660 11 UIKit 0x00ad2ffa -[UIWindow _sendTouchesForEvent:] + 874 12 UIKit 0x00ad3ad5 -[UIWindow sendEvent:] + 791 13 UIKit 0x00a98bb1 -[UIApplication sendEvent:] + 242 14 UIKit 0x00aa8bf6 _UIApplicationHandleEventFromQueueEvent + 21066 15 UIKit 0x00a7cbc7 _UIApplicationHandleEventQueue + 2300 16 CoreFoundation 0x0018a98f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION_ + 15 17 CoreFoundation 0x0018049d __CFRunLoopDoSources0 + 253 18 CoreFoundation 0x0017f9f8 __CFRunLoopRun + 952 19 CoreFoundation 0x0017f37b CFRunLoopRunSpecific + 443 20 CoreFoundation 0x0017f1ab CFRunLoopRunInMode + 123 21 GraphicsServices 0x0400c2c1 GSEventRunModal + 192 22 GraphicsServices 0x0400c0fe GSEventRun + 104 23 UIKit 0x00a809b6 UIApplicationMain + 1526 24 ff 0x0008315e top_level_code + 78 25 ff 0x0008319b main + 43 26 libdyld.dylib 0x023c4ac9 start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)
Can anyone explain what's happening to me ?
3 Answers
Steve Hunter
57,712 PointsThat really does look like you have an additional 'orphan' IBAction attached to the button.
Go into the MainStoryboard and click the 'Connections Inspector' (top right, an arrow surrounded by a ring) and see how many connections you have live by clicking the button outline.
Let me know how you get on with that. The error does appear to be that.
Steve.
nathantopolanski
4,138 PointsHey Steve,
I deleted all my connections and re-made them exactly the same, however this time it worked. The only difference is that I added a description in my code : (sender: AnyObject).
Thanks for the answer,
Nathan
TheBigoso /\
3,217 PointsHello everyone,
Thx Steve for the great response. I just wanted to spell it out for everyone.
Lets start by following Steves instructions: "Go into the MainStoryboard and click the 'Connections Inspector' (top right, an arrow surrounded by a ring) and see how many connections you have live by clicking the button outline."
This is what my connections outline looked like if you scrolled down. For me it started around line 33.
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="277-G6-toK">
<rect key="frame" x="70" y="269" width="180" height="30"/>
<animations/>
<state key="normal" title="Show another fun fact"/>
<connections>
<action selector="showFunFact" destination="BYZ-38-t0r" eventType="touchUpInside" id="Tqa-9B-qwI"/>
<action selector="showFunFact:" destination="BYZ-38-t0r" eventType="touchUpInside" id="Dok-Lu-YAy"/>
can you see that we are preforming two actions and the program can't decide what action to command. I deleted the bottom one as the newest actions typically stack on top of the old ones.
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="277-G6-toK">
<rect key="frame" x="70" y="269" width="180" height="30"/>
<animations/>
<state key="normal" title="Show another fun fact"/>
<connections>
<action selector="showFunFact" destination="BYZ-38-t0r" eventType="touchUpInside" id="Tqa-9B-qwI"/>
// Remove action
Hope this helps someone, TheBigOso