I've been thinking about this and have read through another stackoverflow question regarding the best recommended way to communicate between view controllers. However, the question/answer for that doesn't seem to address the best approach for the reverse behavior.
i.e. to pass data from ParentController
to its ModalController
, we could initialize ModalController
like initWithDataToProcess:
.
But what if we want to do the reverse? How would I notify the previous controller about a new data?
e.g. User clicks on 'new person' button on the ParentController
. I initiate a new ModalController
and present the user with a person editor view via presentModalViewController:
. User clicks on 'done' to add a new person. I dismissModalViewController:
and UI returns to the ParentController
's view.
Using a global field reference in a singleton object (app delegate or other) is bad. delegation (via formal protocol) and notifications (via NSNotificationCenter) seems overkill. Any suggestions?