Search code examples
iphoneiosobjective-cecslidingviewcontroller

ios - ECSlidingViewController "reason: '*** -[__NSArrayM insertObject:atIndex:]"


I'm using the following pages

-MenuViewController
-ViewController(Main)
-ListViewController

ECSlidingViewController created using the menu. ViewController (main) menu on page directly open, but when I try to open a subpage menu with the following line of listviewcontroller get the error:

[self.view addGestureRecognizer:self.slidingViewController.panGesture];

I received the error are as follows:

-[__NSArrayM insertObject:atIndex:]: object cannot be nil'


Solution

  • The NSArray method insertObject:atIndex does not accept nil. If you do want to insert a nil object into an array, or rather, a representation of a nil entry, use [NSNull null], so you have:

    [myArray insertObject[NSNull null] atIndex:myIndex]
    

    In your case, however, probably the root cause of the error is that self.slidingViewController.panGesture is nil.