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
Vetrichelvan Jeyapalpandy
12,056 PointsButtons and IBAction - terminate called throwing an exception
am not able to get passed this video, when i run the program
// main.m // CrystalBall // // Created by Vetrichelvan J on 26/08/13. // Copyright (c) 2013 Vetrichelvan. All rights reserved. //
import <UIKit/UIKit.h>
import "AppDelegate.h"
int main(int argc, char *argv[]) { @autoreleasepool { return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); } }
it goes here and gets passed
here are my files
//
// ViewController.m // CrystalBall // // Created by Vetrichelvan J on 26/08/13. // Copyright (c) 2013 Vetrichelvan. All rights reserved. //
import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
(void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. }
(void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. }
-
(IBAction)buttonPressed:(UIButton *)sender { NSLog(@"adsfs"); } @end
// // ViewController.h // CrystalBall // // Created by Vetrichelvan J on 26/08/13. // Copyright (c) 2013 Vetrichelvan. All rights reserved. //
import <UIKit/UIKit.h>
@interface ViewController : UIViewController
- (IBAction)buttonPressed:(UIButton *)sender;
@end
2 Answers
Patrick Cooney
12,216 PointsCan you tell us what the exception was? It will have the type of exception in the output. If it turns out to be a "not key-value coding compliant" error make sure you have properties and outputs for all buttons. I got stuck with a "key-value" error on my buttons for like 2 days.
Amit Bijlani
Treehouse Guest TeacherIt's possible that you did not create the IBAction properly. Since you are not too far along I would say trash that project and start again. Just make sure you create the IBAction as outlined in the video.
Vetrichelvan Jeyapalpandy
12,056 PointsVetrichelvan Jeyapalpandy
12,056 Points2013-08-27 22:49:54.104 CrystalBall[4268:11303] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<ViewController 0x7553090> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key buttonPressed.' *** First throw call stack: (0x1c90012 0x10cde7e 0x1d18fb1 0xb79e41 0xafb5f8 0xafb0e7 0xb25b58 0x22f019 0x10e1663 0x1c8b45a 0x22db1c 0xf27e7 0xf2dc8 0xf2ff8 0xf3232 0x423d5 0x4276f 0x42905 0x4b917 0xf96c 0x1094b 0x21cb5 0x22beb 0x14698 0x1bebdf9 0x1bebad0 0x1c05bf5 0x1c05962 0x1c36bb6 0x1c35f44 0x1c35e1b 0x1017a 0x11ffc 0x1f0d 0x1e35 0x1) libc++abi.dylib: terminate called throwing an exception (lldb)
Patrick Cooney
12,216 PointsPatrick Cooney
12,216 PointsMake sure you have an outlet and a property for your buttonPressed action. Open your storyboard and viewContoller.h in the assistant editor, select your button, ctrl drag it to viewController.h you'll get a little popup to name it go ahead and call it anything you want. Then open viewContoller.m in the assistant editor,"right click" on your button, you'll get a popup, click the little circle next to "touch up inside" and drag it on top of your existing IBAction. I'm at work and on an ipad so I can't screen shot it right now but if you still haven't figured it out in a couple of hours I'll post a couple screen shots.
Vetrichelvan Jeyapalpandy
12,056 PointsVetrichelvan Jeyapalpandy
12,056 PointsPlease, could u put in some screenshots am still gettin the issue. I think am doin something wrong.
Patrick Cooney
12,216 PointsPatrick Cooney
12,216 PointsI would just listen to Amit and start over.