views:

43

answers:

1

I currently have an NSManagedObjectContext containing 5 Video Objects displayed in a table view.

When a user selects a row, I'm going to push in a new view controller to display object details, and give the user the option to 'add Video to favorites'.

To do this, I want to create a new NSManagedObjectContext, assign the selected Video to it, and push it to the new view controller.

Can someone please explain how I can do this?

My existing code looks something like:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    VideoDetails *vd = [[VideoDetails alloc] initWithStyle:UITableViewStyleGrouped];
    vd.video = [videoArray objectAtIndex:indexPath.row];

    [[self navigationController] pushViewController:vd animated:YES];

}
+2  A: 

Why are you intent on creating a new NSManageObjectContext? Although contexts are relatively cheap, as long as you will not be accessing a context on multiple threads, it's much easier to just use one context and pass a reference to it to the new controller.

Barry Wark