1

My application start with a view thats not use ECSlidingViewController, and then have a button to another that uses it.

In switching the views using Storyboard Segue, but I'm getting error.

What should I add to btnGoSecondView to load ECSlidingViewController properly?


Code:

-(IBAction)btnGoSecondView:(id)sender {
    [self performSegueWithIdentifier:@"SecondViewShow" sender:self];
}

enter image description here


Error:

 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
Luciano Nascimento
  • 2,600
  • 2
  • 44
  • 80

2 Answers2

0

i think you should make some initialview first, and make that view became initial view controller and make an identifier for every each view controller.

something like this ..

self.viewcontroller = [storyboard instantiateViewControllerWithIdentifier:@"home"];

discodisky
  • 39
  • 3
  • Doing this works perfectly, if I indicate to load my SecondView from InitialView. But starting with FristView and using `segue` to switch, it do not work. Any ideas what should be in `btnGoSecondView` to work properly? – Luciano Nascimento Feb 26 '13 at 05:06
  • my suggestion the error is because array in menucontroller, there was a "(void)awakeFromNib" for naming array in menucontroller, so you should give the viewcontroller as same as your "NSArray arrayWithObjects" – discodisky Feb 26 '13 at 06:41
0

Based on the error you're getting an object is trying to be inserted into a mutable array but it hasn't been initialised. Where is the exception thrown in your code?

Try work out where the array is being accessed and why it's null. The NSMutableArray may not have been initialised in which case you'll need to initialise it.

NSMutableArray *arrayName = [NSMutableArray new];

Another thought: Before the ECSlidingViewController is presented I think you need to set it's topViewController. You could add it in -prepareForSegue:sender: or in the viewDidLoad of the viewController to be presented.

Something like this perhaps:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

     ECSlidingViewController *slidingViewController = (ECSlidingViewController *)segue.destinationViewController;
     slidingViewController.topViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"FirstTop"];
}
Dos43
  • 128
  • 10