In UIViewController 1
, I have set up an array. This UIViewController
segues to UIViewController 2
.
In UIViewController 2
, there is a UITableView
with custom UITableViewCell
. There's also a UIButton
which segues perfectly fine back to UIViewController 1
.
In the custom cell, there is a collectionView
. This is populated by the array from ViewController 1
.
My question is, when an item is selected in the collectionView
(UIViewController 2
- custom UITableViewCell
class), how to pass that value all the way back to UIViewController 1
?
I'm sorry if this is repetitive. I've referred to many similar entries here but nothing seems to be working. I've also tried this:
http://www.appcoda.com/ios-collection-view-tutorial/
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"showRecipePhoto"]) {
NSArray *indexPaths = [self.collectionView indexPathsForSelectedItems];
RecipeViewController *destViewController = segue.destinationViewController;
NSIndexPath *indexPath = [indexPaths objectAtIndex:0];
destViewController.recipeImageName = [recipeImages[indexPath.section] objectAtIndex:indexPath.row];
[self.collectionView deselectItemAtIndexPath:indexPath animated:NO];
}
}
I keep getting the null value returned and I'm not sure why.
(I'm not using storyboard. And this is my first attempt at programming of any kind. Would appreciate any input!)