我對此很陌生,並且試圖製作一個簡單的溫度轉換應用程序。下面是有沒有被拋出錯誤:iOS應用程序在測試啓動時拋出錯誤
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
現在,據我所知,有一些錯誤的,我按鈕的功能所以這裏是我的接口和實現:
#import <UIKit/UIKit.h>
@interface TemperatureConverterViewController : UIViewController
@property (weak, nonatomic) IBOutlet UITextField *temperatureField;
@property (weak, nonatomic) IBOutlet UILabel *conversionResult;
- (IBAction)convertToFahrenheit:(id)sender;
@end
繼承人的實現(.M文件)
#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
任何人都可以找到問題嗎?我不能:(
謝謝。
UPDATE!
當我按我的文本字段中的虛擬設備,鍵盤的表演,但它並沒有消失的時候我按下按鈕!任何人都知道我是如何解決這一問題?
太謝謝你了!
檢查您的XIB或故事板的連接,並確保一切都正確掛接。有可能你可能已經連接了一個IBOutlet,你之後從你的界面中刪除了這個IBOutlet,這個IBOutlet仍然在文件所有者連接中出現。 – Aaron
設置異常斷點。當它被擊中時會連續幾次,並且會有錯誤信息。 – zaph
ConvertTemperature按鈕沒有連接 - 可能是一個IBOutlet – GuybrushThreepwood