In CoreData, I have the data graph with some entities, and each object is populated in a view controller, at a defined screen, I want to pop out some (>1) objects to return to a define screen.
I tried to pop the view controllers out of the navigation stack with these lines of code:
ObjectA *objectA = objectD.objectC.objectA;
NSLog(@"objectA name: %@", objectA.name);
MyViewController *controller = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil withObjectA:objectA];
[self.navigationController popToViewController:controller animated:YES];
[controller release];
The objectA, objectB, objectC, objectD are all objects from my data graph(with the inverse relationship, I can query back the objectA from the objectD through objectC)
The following error message is raised:
Assertion failure in -[UINavigationController popToViewController:transition:], /SourceCache/UIKit_Sim/UIKit-984.38/UINavigationController.m:1807
There are two questions here:
- If the two objects are different, how comes they have the same name? the inverse relationship can not get back the objectA in which I used to initialize MyViewController?
- How do you normally do popToViewController? How can I implement save/load the current state of my navigation controller so that when the application quits, I can reload the navigation controller? What are the best practices?