{"id":3270,"date":"2014-03-21T18:27:58","date_gmt":"2014-03-21T18:27:58","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/21\/ecslidingviewcontroller-error-object-cannot-be-nil-when-viewwillappear-collection-of-common-programming-errors\/"},"modified":"2014-03-21T18:27:58","modified_gmt":"2014-03-21T18:27:58","slug":"ecslidingviewcontroller-error-object-cannot-be-nil-when-viewwillappear-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/21\/ecslidingviewcontroller-error-object-cannot-be-nil-when-viewwillappear-collection-of-common-programming-errors\/","title":{"rendered":"ECSlidingViewController error (object cannot be nil) when viewWillAppear-Collection of common programming errors"},"content":{"rendered":"<p>In my app I&#8217;ve a navigation Controller that is connected to another viewController (root controller). In my project I&#8217;ve imported ECSlidingViewController.h and .m. In the viewController that will be used as a right-side menu (listViewController.h), I&#8217;ve imported ECSlidingViewController.h and in viewDidLoad I did this:<\/p>\n<pre><code>[super viewDidLoad];\n    self.peekLeftAmount = 40.0f;\n    [self.slidingViewController setAnchorLeftPeekAmount:self.peekLeftAmount];\n    self.slidingViewController.underRightWidthLayout = ECVariableRevealWidth;\n<\/code><\/pre>\n<p>In the navigationController class instead, I did this (after imported ECSlidingViewController.h and listViewController.h):<\/p>\n<pre><code>- (void)viewWillAppear:(BOOL)animated\n{\n    [super viewWillAppear:animated];\n\n    if (![self.slidingViewController.underRightViewController isKindOfClass:[ListViewController class]]) {\n        self.slidingViewController.underRightViewController  = [self.storyboard instantiateViewControllerWithIdentifier:@\"ListStore\"];\n    }\n\n    [self.view addGestureRecognizer:self.slidingViewController.panGesture];\n}\n<\/code><\/pre>\n<p>But when I run the app, when I get to the line of code <code>[self.view addGestureRecognizer:self.slidingViewController.panGesture];<\/code> the app crashes, and gives me the following error:<\/p>\n<pre><code>2013-09-28 01:59:55.629 Myapp[2627:a0b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'\n*** First throw call stack:\n(\n    0   CoreFoundation                      0x024595e4 __exceptionPreprocess + 180\n    1   libobjc.A.dylib                     0x01a6f8b6 objc_exception_throw + 44\n    2   CoreFoundation                      0x0240bc3c -[__NSArrayM insertObject:atIndex:] + 844\n    3   CoreFoundation                      0x0240b8e0 -[__NSArrayM addObject:] + 64\n    4   UIKit                               0x0063f497 -[UIView(UIViewGestures) addGestureRecognizer:] + 208\n    5   Myapp                              0x0001a934 -[MainNavigationController viewWillAppear:] + 564\n    6   UIKit                               0x006ec28a -[UIViewController _setViewAppearState:isAnimating:] + 419\n    7   UIKit                               0x006ec798 -[UIViewController __viewWillAppear:] + 114\n    8   UIKit                               0x006fd310 -[UIViewController(UIContainerViewControllerProtectedMethods) beginAppearanceTransition:animated:] + 199\n    9   UIKit                               0x0097d627 -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:animation:] + 6236\n    10  UIKit                               0x006f478c -[UIViewController presentViewController:withTransition:completion:] + 6433\n    11  UIKit                               0x006f4caf -[UIViewController presentViewController:animated:completion:] + 130\n    12  Myapp                              0x00017447 -[SplashScreenViewController viewDidAppear:] + 839\n    13  UIKit                               0x006ec2d8 -[UIViewController _setViewAppearState:isAnimating:] + 497\n    14  UIKit                               0x006ec867 -[UIViewController __viewDidAppear:] + 146\n    15  UIKit                               0x006ee22f __64-[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:]_block_invoke + 44\n    16  UIKit                               0x006ecbfa -[UIViewController _executeAfterAppearanceBlock] + 63\n    17  UIKit                               0x005f1d59 ___afterCACommitHandler_block_invoke_2 + 33\n    18  UIKit                               0x005f1cde _applyBlockToCFArrayCopiedToStack + 403\n    19  UIKit                               0x005f1b2e _afterCACommitHandler + 568\n    20  CoreFoundation                      0x0242153e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30\n    21  CoreFoundation                      0x0242148f __CFRunLoopDoObservers + 399\n    22  CoreFoundation                      0x023ff3b4 __CFRunLoopRun + 1076\n    23  CoreFoundation                      0x023feb33 CFRunLoopRunSpecific + 467\n    24  CoreFoundation                      0x023fe94b CFRunLoopRunInMode + 123\n    25  GraphicsServices                    0x032da9d7 GSEventRunModal + 192\n    26  GraphicsServices                    0x032da7fe GSEventRun + 104\n    27  UIKit                               0x005d594b UIApplicationMain + 1225\n    28  Myapp                              0x00002b2b main + 235\n    29  libdyld.dylib                       0x01f54725 start + 0\n    30  ???                                 0x00000001 0x0 + 1\n)\nlibc++abi.dylib: terminating with uncaught exception of type NSException\n<\/code><\/pre>\n<p>Please, help me!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In my app I&#8217;ve a navigation Controller that is connected to another viewController (root controller). In my project I&#8217;ve imported ECSlidingViewController.h and .m. In the viewController that will be used as a right-side menu (listViewController.h), I&#8217;ve imported ECSlidingViewController.h and in viewDidLoad I did this: [super viewDidLoad]; self.peekLeftAmount = 40.0f; [self.slidingViewController setAnchorLeftPeekAmount:self.peekLeftAmount]; self.slidingViewController.underRightWidthLayout = ECVariableRevealWidth; In [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3270","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3270","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=3270"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3270\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=3270"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=3270"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=3270"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}