0

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.

user1904273
  • 4,562
  • 11
  • 45
  • 96

1 Answers1

0

Have you tried storing the property for managed object context in controller1 and using an exit segue to pass back the controller2 state and hence use that to instantiate the managedobjectcontext stored in controller1. Should work.

Rajive Jain
  • 758
  • 6
  • 7