views:

67

answers:

2

So I have (for instance) three views:

A: root view
B: a view functionally identical to root
C: a data entry view which collects a few piece of info

What I'm trying to do is reuse C to supply the data it collects to either A or B. It should supply the data to whichever of the two it is pushed onto. The data for A is similar, but functionally distinct, to what collects for B.

Right now, I'm passing data from C to A or B via a singleton class. What I'm trying to avoid is having two instances of C, one to supply data to A and B (because, in actuality, the program will have 5 total views like C.

Does the question make sense?

A: 

Firstly it should be your view controllers getting data and not your views, the view controllers will feed in data to their views accordingly...Now assuming root view controller A knows of the rest of the view controllers (B C D E) then i would suggest to define a protocol in view controller C that root view controller A can conform to, that way u can pass data to A, and from A you can distribute the data onto to B since A is your root controller which knows of all the other controllers... hope that helps

Daniel
A: 

use protocol/delegates. on the save of your viewcontroller c, call the delegate that initially pushed c and passed the data along with it. In the implementation of the protocol in a or b, do your saving with the passed in value.

Joo Park