I have a modal controller controller2 that edits a view, created modally by controller1. modal controller2 is configured in storyboard but launched from controller1 in following code in viewdidload as follows.
UIBarButtonItem *editButton = [[UIBarButtonItem alloc]
initWithTitle:@"Edit"
style:UIBarButtonItemStylePlain
target:self
action:
//next line calls method editView
@selector(editView:)];
self.navigationItem.rightBarButtonItem = editButton;
When I dismiss controller2 after saving changes, I want change in the managedobjectcontext to be carried over to controller1.
Some examples on SO suggest using the following:
[controllerTarget setManagedObjectContext:[self managedObjectContext]];
which would go in controller2 right before dismissing it.
However, trying to do this gives an error "No Known Class Method" suggesting that I have to instantiate controller 1. However, I don't want to create a new instance of controller1 and pass managed object context to it. I want to pass managedobjectcontext to instance of controller1 already in navigation stack.
Would appreciate any suggestions how to make this work.
Thank you.