I am fairly new to developing in Swift, and I seem to be struggling with one of the key concepts.
I am looking to pass data between different UIViewControllers, allowing them all to access and manipulate it.
For example, in my application, I have created a simple data store class that contains and array of items. I want this array to be accessible by all ViewControllers.
I initialise the store within AppDelegate:
var itemStore = ItemStore()
I then create the first UIViewController and pass in the store so that it has access to it:
FirstViewController(itemStore: ItemStore)
So to do this I need to make changes to the init of FirstViewController so that it is able to accept itemStore as an argument.
I then want to pass that data to SecondViewController, and then to ThirdDataController.
It seems unnecessary to me that I have to edit every single UIViewController class so that it accepts the itemStore as an argument.
What are my options here? Some people have told me to store the data as a property of AppDelegate so that it is accessible by all. However, it seems that is not the right way of doing it.
Any advice?