I’m asking what is probably a fundamental question but I’m relatively new to iOS and Object Oriented Programming:
Question:
If I have a simple app with 2 Views & View Controllers that receives input from each, how should I structure my program so that I can reference the values that were inputed in each view controller and take these values, add them together (as an example), and then output it to say a 3rd View Controller?
If this was all done in the same controller then I can do it but the issue is where can I store this so that the data is available across multiple controllers?
Fundamentally I’m not sure where the ‘processing (addition) should occur. Should this be in another class, or AppDelegate? Is this termed the ‘model’ in MVC and can multiple View Controllers reference the same model?
I’m sure this is really basic stuff but an example or reference to material will really help clarify this for me.
Thanks
You can use NSUserDefaults to store the shared data or you can implement your own shared storage object as singleton, here’s one tutorial for creating singleton object in obj-c with demo project.