In my app, users are able to drill down from a series of episodes to an individual episode. In the individual episode the users are supposed to be able to go to the next and previous episodes using buttons.
As it stands right now, when user is in the ViewSeries screen and clicks an epiosode, the accessoryButtonTapped method assigns the indexPath of the selected episode to the ViewEpisode screen like this:
Code:
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {
ViewEpisodeController *viewEpisodeController = [[ViewEpisodeController alloc] initWithNibName:@"ViewEpisode" bundle:nil];
viewEpisodeController.episode = ((Episode *)[[episodeSet episodes] objectAtIndex:indexPath.row]);
viewEpisodeController.parentEpisodeSet = episodeSet;
viewEpisodeController.episodeIndexPath = indexPath;
[self.navigationController pushViewController:viewEpisodeController animated:YES];
[viewEpisodeController release];
}
}
so I can perform operations like this in the ViewEpisode screen:
Code:
-(IBAction)switchToPreviousEpisode:(id)sender {
ViewEpisodeInnerTableViewController *temp_inner_table = [[ViewEpisodeInnerTableViewController alloc] init];
Episode *previousEpisode = [[parentEpisodeSet episodes] objectAtIndex:episodeIndexPath.row -1];
self.episodeIndexPath = [[parentEpisodeSet episodes] objectAtIndex:episodeIndexPath.row -1];
temp_inner_table.episode = previousEpisode;
self.previousViewEpisodeInnerTableViewController = temp_inner_table;
[temp_inner_table release];
}
My question: Is this the best way to navigate from an object in an array to the next and previous objects? Is there a better way to do this whole thing? I am quite new, so thanks for your patience!