objective-cios8-today-widget

UITableViewController in iOS 8 Today Extension


I'm trying to add UITableViewController to Today Widget, but every time I drag UITableViewController to Storyboard and run the Widget it crashes with the following error.

I've tried multiple times. I've tried it by using Table View object, but problem persists.

Note: It crashes even before loading viewDidLoad() method.

2015-06-06 01:19:20.569 iOSHackerToday[3202:283287] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[NSArrayM insertObject:atIndex:]: object cannot be nil' *** First throw call stack: ( 0 CoreFoundation 0x0000000107842c65 __exceptionPreprocess + 165 1 libobjc.A.dylib
0x00000001074dbbb7 objc_exception_throw + 45 2 CoreFoundation
0x000000010770f8ca -[__NSArrayM insertObject:atIndex:] + 954 3
UIKit 0x0000000107d6f0b9 -[UIViewController _addChildViewController:performHierarchyCheck:notifyWillMove:] + 338 4 UIKit 0x0000000108241a0c -[_UIViewServiceViewControllerOperator __createViewController:withContextToken:fbsDisplays:appearanceSerializedRepresentations:legacyAppearance:traitCollection:initialInterfaceOrientation:hostAccessibilityServerPort:canShowTextServices:replyHandler:] + 2216 5 CoreFoundation 0x0000000107738dec __invoking_
+ 140 6 CoreFoundation 0x0000000107738c42 -[NSInvocation invoke] + 290 7 CoreFoundation
0x00000001077c9016 -[NSInvocation invokeWithTarget:] + 54 8 UIKit
0x00000001082fd01b -[_UIViewServiceImplicitAnimationDecodingProxy forwardInvocation:] + 222 9 CoreFoundation
0x000000010779ff4f forwarding + 495 10 CoreFoundation
0x000000010779fcd8 _CF_forwarding_prep_0 + 120 11 CoreFoundation
0x0000000107738dec invoking_ + 140 12 CoreFoundation
0x0000000107738c42 -[NSInvocation invoke] + 290 13 CoreFoundation
0x00000001077c9016 -[NSInvocation invokeWithTarget:] + 54 14 UIKit
0x00000001082889f4 -[_UIQueueingProxy forwardInvocation:] + 319 15 CoreFoundation 0x000000010779ff4f forwarding + 495 16 CoreFoundation 0x000000010779fcd8 _CF_forwarding_prep_0 + 120 17 CoreFoundation
0x0000000107738dec invoking_ + 140 18 CoreFoundation
0x0000000107738c42 -[NSInvocation invoke] + 290 19 CoreFoundation
0x00000001077c9016 -[NSInvocation invokeWithTarget:] + 54 20 CoreFoundation 0x000000010779ff4f forwarding + 495 21 CoreFoundation 0x000000010779fcd8 _CF_forwarding_prep_0 + 120 22 CoreFoundation
0x0000000107738dec invoking_ + 140 23 CoreFoundation
0x0000000107738c42 -[NSInvocation invoke] + 290 24 libdispatch.dylib 0x0000000109da6f16 _dispatch_call_block_and_release + 12 25 libdispatch.dylib 0x0000000109dc1964 _dispatch_client_callout + 8 26 libdispatch.dylib 0x0000000109daca59 _dispatch_main_queue_callback_4CF + 704 27 CoreFoundation 0x00000001077aa1f9 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 9 28 CoreFoundation 0x000000010776bdcb __CFRunLoopRun + 2043 29 CoreFoundation 0x000000010776b366 CFRunLoopRunSpecific + 470 30 GraphicsServices
0x000000010b01ca3e GSEventRunModal + 161 31 UIKit
0x0000000107c3b900 UIApplicationMain + 1282 32 libxpc.dylib
0x000000010a0a7aec _xpc_objc_main + 453 33 libxpc.dylib
0x000000010a0a9e91 xpc_main + 185 34 Foundation
0x0000000107209ee1 service_connection_handler + 0 35 PlugInKit
0x0000000106ff3a82 -[PKService run] + 521 36 PlugInKit
0x0000000106ff3747 +[PKService main] + 55 37 PlugInKit
0x0000000106ff3aa6 +[PKService _defaultRun:arguments:] + 17 38 libextension.dylib 0x000000010978399d NSExtensionMain + 51 39 libdyld.dylib 0x0000000109df1145 start + 1 40 ??? 0x0000000000000001 0x0 + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)


Solution

  • When you delete the default layout and drag a new table view controller, you need to mark the new view controller as 'Intial View Controller'

    Mark as initial view controller

    Here's the Apple's document which explains how to do it. https://developer.apple.com/library/ios/recipes/xcode_help-IB_storyboard/chapters/SetInitialController.html