0

I tried following the Stanford iphone development tutorial and I got stuck because my iPhone app is crashing. Help!

Error message

2013-03-03 12:10:39.055 RPN Calculator[2166:11303] * Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key digitPressed.

Header

import <UIKit/UIKit.h>
@interface CalculatorViewController : UIViewController
@property (weak, nonatomic) IBOutlet UILabel *display;
@end

Implementation

#import "CalculatorViewController.h"
@interface CalculatorViewController ()
@end
@implementation CalculatorViewController

- (IBAction)digitPressed:(UIButton *)sender {
      NSString *digit = [sender currentTitle];
      NSLog(@"Digit pressed = %@", digit);
}
@end
nsgulliver
  • 12,655
  • 23
  • 43
  • 64
Hovanky
  • 303
  • 1
  • 3
  • 15

2 Answers2

4

You probably created an IBOutlet digitPressed instead of an IBAction. So realizing this, deleted the code from your .h and .m file. But forgot to remove the connection from .xib (happened to me also when I started off). If that is the case, you can right click on your button for which the IBAction is called and delete the connection.

Rakesh
  • 3,370
  • 2
  • 23
  • 41
2

your problem might be that your action method digitPresses is not assigned properly with the UIButton defined in your .xib or storyboard and it is missing the link defined in your code, you could check that it in the connection inspector and make sure you are connecting the action with the touch up inside event

nsgulliver
  • 12,655
  • 23
  • 43
  • 64