I’ve just found that passing an NSManagedObjectContext object via a segue in iOS 5 doesn’t work: the property remains empty.
In iOS 6 on the other hand this isn’t a problem: the context arrives just like any other property would, and as logic would dictate. Here’s code from an amended Utility Template app:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([[segue identifier] isEqualToString:@"showAlternate"]) { // also onpass the managed object context self.flipsideViewController = [[FlipsideViewController alloc]init]; self.flipsideViewController.managedObjectContext = self.managedObjectContext; self.flipsideViewController = segue.destinationViewController; self.flipsideViewController.delegate = self; } }
Trying to execute a Fetch Request on FlipsideViewController results in this error message:
+entityForName: could not locate an NSManagedObjectModel for entity name ‘YourEntity’
The fact that this is fixed (yet completely undocumented) means that Apple knew about this and made it work in iOS 6. Why this doesn’t work in iOS 5 is anyone’s guess.