VCs are responsible for parts of the model. They react to user actions by changing the model, and they observe changes in the model to update their views. They communicate with each other indirectly, because they both observe the same shared model.
To recap my answer to your other question, when vcA which presents an array of model objects in a tableview wants to tell vcB on which specific object to operate, it can do so directly by assigning that object to a vcB property which is vcB's part of the model....
vcA vcB
| /
vcA's model vcB's model (assigned to it before a segue)
| /
---------------- /
| | | /
obj0 obj1 obj2
Before presenting vcB, vcA assigns it part of the model (obj2, in this example).
See how there's no need to "pass back" anything from vcB to vcA? They're both looking at the same thing. While true, this leaves unanswered some questions implied by your post...
vcA probably needs to know if vcB changes the model so it can
update its views. Doesn't vcB need to tell vcA about that?
This is a big topic, but the short answer is that vcA can observe the model changing using KVO and notification.
What about delegation? Is that a way for vcs to coordinate?
Yes. Notification is sometimes a little too broadcast-y and KVO is sometimes a little too narrow and verbose. With delegation, vcB says to its delegate: "I'll do my job of changing my part of the model, and you should do whatever it is you do when I do what I do".
This highly rated post on the subject of inter-vc communication does a good job explaining how to implement delegation.
Delegation is a little over-prescribed, imo. I prefer to use it for richer interactions (the way NSURLConnectionDelegate
or UITableViewDatasource
works), but using it between vcs to communicate about model changes is common practice that works.
How about the "target-action" pattern?
You didn't mention this one, but its another pattern, delegation's hackier cousin. Outside of custom UIControl subclasses, I'd stay away.
What about global variables? Are they bad?
Yes.
A more subtle answer allows for a commonly used few, including a singleton root of your model. But in general, you should avoid globals for the same reason you don't use wooden clubs: for most (non-bludgeoning-related) jobs, they do more harm than good.
What about my ToolBox class or CoreData or NSUserDefaults?
Your ToolBox class might really be part of your model, maybe you just haven't realized it or named it that way. CoreData for persistence of the model between app launches. Not really pertinent here. NSUserDefaults is persistence of user prefs between launches, also not pertinent.
Using these instead of the patterns sanctioned above is like using global variables, except a little worse, because they are often applied as global variables, only renamed to obscure the ill-advised approach.