我有一个最初为 iOS 6 编写的应用程序,但我现在希望它可以在 iOS 7 上运行。我在 Xcode 5 中打开了该项目并编辑了一些东西。它工作得很好,除了一条错误消息Need a root view controller before launch
(我不记得确切的措辞)。这对我来说似乎很奇怪,因为设置了 rootViewController 并且应用程序仍然可以正常工作。[self.window makeKeyAndVisible]
然后我又编辑了一些,现在在调用该行时收到以下错误消息:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
*** First throw call stack:
(
0 CoreFoundation 0x01f155e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x01b058b6 objc_exception_throw + 44
2 CoreFoundation 0x01ec7c3c -[__NSArrayM insertObject:atIndex:] + 844
3 CoreFoundation 0x01ec78e0 -[__NSArrayM addObject:] + 64
4 Nobles 0x00003efd -[AppDelegate addReachabilityDisabledButton:] + 109
5 Nobles 0x00014f4c -[FoodViewController viewDidLoad] + 188
6 UIKit 0x0077e9a8 -[UIViewController loadViewIfRequired] + 696
7 UIKit 0x0077ec44 -[UIViewController view] + 35
8 Nobles 0x000129fa -[MenuViewController viewDidLoad] + 1322
9 UIKit 0x0077e9a8 -[UIViewController loadViewIfRequired] + 696
10 UIKit 0x0077ec44 -[UIViewController view] + 35
11 UIKit 0x006a75ad -[UIWindow addRootViewControllerViewIfPossible] + 66
12 UIKit 0x006a7947 -[UIWindow _setHidden:forced:] + 312
13 UIKit 0x006a7bdd -[UIWindow _orderFrontWithoutMakingKey] + 49
14 UIKit 0x006b244a -[UIWindow makeKeyAndVisible] + 65
15 Nobles 0x000036b2 -[AppDelegate application:didFinishLaunchingWithOptions:] + 2642
16 UIKit 0x00664f65 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 309
17 UIKit 0x006657a5 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1536
18 UIKit 0x00669fb8 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
19 UIKit 0x0067e42c -[UIApplication handleEvent:withNewEvent:] + 3447
20 UIKit 0x0067e999 -[UIApplication sendEvent:] + 85
21 UIKit 0x0066bc35 _UIApplicationHandleEvent + 736
22 GraphicsServices 0x034912eb _PurpleEventCallback + 776
23 GraphicsServices 0x03490df6 PurpleEventCallback + 46
24 CoreFoundation 0x01e90dd5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
25 CoreFoundation 0x01e90b0b __CFRunLoopDoSource1 + 523
26 CoreFoundation 0x01ebb7ec __CFRunLoopRun + 2156
27 CoreFoundation 0x01ebab33 CFRunLoopRunSpecific + 467
28 CoreFoundation 0x01eba94b CFRunLoopRunInMode + 123
29 UIKit 0x006696ed -[UIApplication _run] + 840
30 UIKit 0x0066b94b UIApplicationMain + 1225
31 Nobles 0x00002c2d main + 141
32 libdyld.dylib 0x0317f725 start + 0
)
libc++abi.dylib: terminating with uncaught exception of type NSException
在调用此行 if 之前,我检查了 rootViewController 是否为 nil,但事实并非如此。在此错误开始之前,我没有修改 AppDelegate。
有任何想法吗?
提前致谢。