我的代碼編譯但我在嘗試啓動時遇到運行時錯誤。嘗試構建基於iOS應用程序的簡單UITabBarController時出現運行時錯誤
下面是運行時錯誤:
2011-04-25 23:56:40.689 Noun[39033:207] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<NounAppDelegate 0x4e1c400> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key viewController.'
*** Call stack at first throw:
(
0 CoreFoundation 0x00dc75a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00f1b313 objc_exception_throw + 44
2 CoreFoundation 0x00dc74e1 -[NSException raise] + 17
3 Foundation 0x0002f677 _NSSetUsingKeyValueSetter + 135
4 Foundation 0x0002f5e5 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 285
5 UIKit 0x004b330c -[UIRuntimeOutletConnection connect] + 112
6 CoreFoundation 0x00d3d8cf -[NSArray makeObjectsPerformSelector:] + 239
7 UIKit 0x004b1d23 -[UINib instantiateWithOwner:options:] + 1041
8 UIKit 0x004b3ab7 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168
9 UIKit 0x002b917a -[UIApplication _loadMainNibFile] + 172
10 UIKit 0x002b9cf4 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 291
11 UIKit 0x002c4617 -[UIApplication handleEvent:withNewEvent:] + 1533
12 UIKit 0x002bcabf -[UIApplication sendEvent:] + 71
13 UIKit 0x002c1f2e _UIApplicationHandleEvent + 7576
14 GraphicsServices 0x0171f992 PurpleEventCallback + 1550
15 CoreFoundation 0x00da8944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
16 CoreFoundation 0x00d08cf7 __CFRunLoopDoSource1 + 215
17 CoreFoundation 0x00d05f83 __CFRunLoopRun + 979
18 CoreFoundation 0x00d05840 CFRunLoopRunSpecific + 208
19 CoreFoundation 0x00d05761 CFRunLoopRunInMode + 97
20 UIKit 0x002b97d2 -[UIApplication _run] + 623
21 UIKit 0x002c5c93 UIApplicationMain + 1160
22 Noun 0x00001e68 main + 102
23 Noun 0x00001df9 start + 53
)
terminate called after throwing an instance of 'NSException'
這裏是我的代碼(相關方法)
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//Initiate TabBarController
self.tabBarController = [[UITabBarController alloc] init];
NSMutableArray *viewControllersForTabController = [[NSMutableArray alloc] initWithCapacity:2];
NounViewController *firstViewController = [[NounViewController alloc] initWithNibName:@"NounViewController" bundle:[NSBundle mainBundle]];
[viewControllersForTabController addObject:firstViewController];
[firstViewController release];
PostLoginViewController *secondViewController = [[PostLoginViewController alloc] initWithNibName:@"PostLoginViewController" bundle:[NSBundle mainBundle]];
[viewControllersForTabController addObject:secondViewController];
[secondViewController release];
[tabBarController setViewControllers:viewControllersForTabController];
[viewControllersForTabController release];
[window addSubview:tabBarController.view];
return YES;
}
我敢肯定,這可能是一些小事,我已經忘了做,我在iOS開發中慢慢加快速度
謝謝saadnib,我在我的plist文件和筆尖上打字。這不是很明顯。 – 2011-04-26 04:45:34