IOS 7 makeKeyAndVisible Not Working

0

I have an app which I originally wrote for iOS 6 but I now want it to work on iOS 7. I opened the project up in Xcode 5 and edited some stuff. It worked fine, except for an error message along the lines of Need a root view controller before launch(I do not remember the exact wording). This seemed strange to me as the rootViewController was set and the app still worked fine. I then edited some more and now I get the following error message when the line [self.window makeKeyAndVisible] is called:

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

I checked to see if the rootViewController was nil before calling this line if , but it was not. I did not modify the AppDelegate before this error started.

Any ideas?

Thanks in advance.

iphone
ios
objective-c
ios7
asked on Stack Overflow Sep 19, 2013 by carloabelli • edited Sep 19, 2013 by carloabelli

1 Answer

1

It looks like the issue is in -[AppDelegate addReachabilityDisabledButton:] This function is getting called from -[FoodViewController viewDidLoad]. I'm assuming a button is being passed in that is nil. Check the xib for FoodViewController, to make sure the outlet is set. The new format for xibs has occasionally posed problems for me, so it may just require opening the file, checking the outlet and saving.

If that doesn't work set a breakpoint at [FoodViewController viewDidLoad] and try to inspect the value for the object that is being passed in.

answered on Stack Overflow Sep 19, 2013 by Saltymule

User contributions licensed under CC BY-SA 3.0