Jeremy Evans
Jeremy Evans

Reputation: 41

Passing object through segue

Long story short I have a project that I am working on with my gf. Its a vegan recipe book for vegans that dat meat eaters or vice versus or just vegan on vegan action. Any who, I have a problem passing the data from my view table to my view controller. It seems that the first time I push the cell it is nil. then I hit back then hit it again and it goes through, BUT... once I hit back again its like my array switches names with sources. link to project provided provided because it is too much code to input here.

Link to project

Upvotes: 1

Views: 106

Answers (1)

Skyler Lauren
Skyler Lauren

Reputation: 3812

Took me a bit to track it down but I believe your issue is that you are trying to segue directly from the table cell. The segue is happing before you are able to set the instance variable.

Remove that segue in your story board and recreate it going directly from Recipe List to Recipe Info. Don't forget to put your segue identifier back on.

Now it should be a simple matter of calling this in didSelectRow

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Set selected location to var
    _selectedLocation = _feedItems[indexPath.row];

    [self performSegueWithIdentifier:@"recipeInfo" sender:nil];
}

Also in the future your project may be complex, but you know roughly where you issue was. Putting in the code for RecipeList.m, RecipeInfo.h, and RecipeInfo.m would have lead most to where they can help you instead of digging through the project. Not complaining but just trying to help you get questions answered faster if someone isn't willing to dig through your project.

Upvotes: 1

Related Questions