I’m setting a property for a viewcontroller which I set on a prepareForSegue method. Then this viewcontroller is shown through an item in a TabBar which is pushed using segues
The thing is that this property I’m setting for this viewcontroller will be used in 3 views (all of them accesible through the tabbarviewcontroller).
Basically I have:
| View Controller | -> | TabBarController | -> |ViewController|
-> |ViewController|
-> |ViewController|
What’s the best way to share data between all that viewcontrollers?
I’m thinking of using a singleton as a manager and instead of setting a property in the prepareForSegue method, set the value in this manager and call it in all the views but maybe there’s a better way to achieve this.
If you are going to share data among the three view controllers, I guess the best approach would be creating a “model” object (as in model-view-controller), and make it available to all the objects in your app.
A singleton would be perfect for this and you could modify it as required in
prepareForSegue, before your view controllers will need to access it.