IOS app throwing error on test launch

-2

I'm new to this and am trying to make a simple temperature conversion application. Here is there error that is being thrown:

2014-02-28 20:35:46.954 Temperature Converter[5899:70b] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<TemperatureConverterViewController 0x8a939a0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key convertTemperatureButton.'
*** First throw call stack:
(
0   CoreFoundation                      0x017395e4 __exceptionPreprocess + 180
1   libobjc.A.dylib                     0x014bc8b6 objc_exception_throw + 44
2   CoreFoundation                      0x017c96a1 -[NSException raise] + 17
3   Foundation                          0x0117d9ee -[NSObject(NSKeyValueCoding) setValue:forUndefinedKey:] + 282
4   Foundation                          0x010e9cfb _NSSetUsingKeyValueSetter + 88
5   Foundation                          0x010e9253 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 267
6   Foundation                          0x0114b70a -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 412
7   UIKit                               0x004cca15 -[UIRuntimeOutletConnection connect] + 106
8   libobjc.A.dylib                     0x014ce7d2 -[NSObject performSelector:] + 62
9   CoreFoundation                      0x01734b6a -[NSArray makeObjectsPerformSelector:] + 314
10  UIKit                               0x004cb56e -[UINib instantiateWithOwner:options:] + 1417
11  UIKit                               0x0033d605 -[UIViewController _loadViewFromNibNamed:bundle:] + 280
12  UIKit                               0x0033ddad -[UIViewController loadView] + 302
13  UIKit                               0x0033e0ae -[UIViewController loadViewIfRequired] + 78
14  UIKit                               0x0033e5b4 -[UIViewController view] + 35
15  UIKit                               0x002669fd -[UIWindow addRootViewControllerViewIfPossible] + 66
16  UIKit                               0x00266d97 -[UIWindow _setHidden:forced:] + 312
17  UIKit                               0x0026702d -[UIWindow _orderFrontWithoutMakingKey] + 49
18  UIKit                               0x0027189a -[UIWindow makeKeyAndVisible] + 65
19  UIKit                               0x00224cd0 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1851
20  UIKit                               0x002293a8 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
21  UIKit                               0x0023d87c -[UIApplication handleEvent:withNewEvent:] + 3447
22  UIKit                               0x0023dde9 -[UIApplication sendEvent:] + 85
23  UIKit                               0x0022b025 _UIApplicationHandleEvent + 736
24  GraphicsServices                    0x036e02f6 _PurpleEventCallback + 776
25  GraphicsServices                    0x036dfe01 PurpleEventCallback + 46
26  CoreFoundation                      0x016b4d65 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
27  CoreFoundation                      0x016b4a9b __CFRunLoopDoSource1 + 523
28  CoreFoundation                      0x016df77c __CFRunLoopRun + 2156
29  CoreFoundation                      0x016deac3 CFRunLoopRunSpecific + 467
30  CoreFoundation                      0x016de8db CFRunLoopRunInMode + 123
31  UIKit                               0x00228add -[UIApplication _run] + 840
32  UIKit                               0x0022ad3b UIApplicationMain + 1225
33  Temperature Converter               0x00002eed main + 141
34  libdyld.dylib                       0x01d7770d start + 1
35  ???                                 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Now, I understand that there is something wrong in my button function so here is my interface and implementation:

#import <UIKit/UIKit.h>

@interface TemperatureConverterViewController : UIViewController

@property (weak, nonatomic) IBOutlet UITextField *temperatureField;
@property (weak, nonatomic) IBOutlet UILabel *conversionResult;

- (IBAction)convertToFahrenheit:(id)sender;

@end

Heres the implementation (.m file)

#import "TemperatureConverterViewController.h"

@interface TemperatureConverterViewController ()

@end

@implementation TemperatureConverterViewController

- (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)convertToFahrenheit:(id)sender {
    double celsius = [_temperatureField.text doubleValue];
    double fahrenheit = (celsius+32)*1.8;
    NSString *result = [[NSString alloc] initWithFormat: @"Fahrenheit: %f",fahrenheit];
    _conversionResult.text = result;
}
@end

Can anyone find the issue? I can't :(

Thank you.


UPDATE!!!

When i press my text field in the virtual device, the keyboard shows, but it doesn't disappear when i press the button! Anyone know how i can fix this?

Thank you so much!


ios
objective-c
asked on Stack Overflow Feb 28, 2014 by rshah • edited Feb 28, 2014 by rshah

2 Answers

1

Check the connections on your XIB or Storyboard and make sure that everything is hooked up properly. I bet you hooked up an IBOutlet that you later deleted from your interface that is still hanging around in the Files Owner connections.

To address the second issue and to dismiss the keyboard try the following in your IBAction:

[self.temperatureField resignFirstResponder];
answered on Stack Overflow Feb 28, 2014 by Aaron • edited Feb 28, 2014 by Aaron
0

You have not set your UIViewController's class as TemperatureConverterViewControllerclass in the interface build.

Setting the class will solve your problem.. Did it for me atleast

answered on Stack Overflow Feb 28, 2014 by Harsh

User contributions licensed under CC BY-SA 3.0