There are 2 buttons in the ViewController . In NextViewController you need to determine which of the buttons was pressed and, based on this, select which array to work with.
I tried to pass the index but it does not work
ViewController.h
@property (nonatomic, assign) NSInteger index; ViewController.m
-(IBAction)Method1:(id)sender { self.index = 1; [self performSegueWithIdentifier:@"Segue" sender:self]; } -(IBAction)Method2:(id)sender { self.index = 2; [self performSegueWithIdentifier:@"Segue" sender:self]; } - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { ViewController *dvc=[segue destinationViewController]; dvc.index = _index; } if (self.index == 2){ _data1 = [[NSArray alloc] initWithObjects: [UIImage imageNamed:@"1.png"],[UIImage imageNamed:@"2.png"],nil] } if (self.index == 2){ _data2 = [[NSArray alloc] initWithObjects: [UIImage imageNamed:@"5.png"],[UIImage imageNamed:@"6.png"],nil] } Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[RootViewController setIndex:]: unrecognized selector sent to instance 0x7faff1f18c30'