我有一个应用程序,我最初为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
我在调用此行之前检查rootViewController是否为nil,但事实并非如此。在此错误开始之前,我没有修改AppDelegate。
有什么想法吗?
提前致谢。
答案 0 :(得分:1)
看起来问题出在 - [AppDelegate addReachabilityDisabledButton:]这个函数是从 - [FoodViewController viewDidLoad]调用的。我假设传递的按钮是零。检查xib for FoodViewController,确保设置了插座。 xibs的新格式偶尔会给我带来问题,所以它可能只需要打开文件,检查插座并保存。
如果不起作用,请在[FoodViewController viewDidLoad]设置断点,并尝试检查传入的对象的值。