Make the app in Swift. The server is loaded with an array of some objects to be accessed in the future I want to have various controllers, or if one, I don't want to redownload the data. The question is how to write the model(at least some pattern or a simple but concrete example), which properties and protocols to realize how to organize the storage of these data and access them throughout the lifetime of the application? Once I implemented the class model according to the principle of Singleton sharedInstance wrote, but it seems to me that there is a correct and suitable solution-patterns.
PS With design patterns I have read, not sure that they directly relate to my problem, and if so, they describe and operate on more abstract and global entities, rules of engagement, etc. And I'm interested in a specific example, for example, where in the controller to initialize the object model should make it a property of the controller or a property of a singleton or do things differently?
Make the database-a controller that: stores all the data, issues a data request, stores the data on request
Make a Factory that creates all controllers (and DB too)
When you create a controller that needs to communicate with DB Factory, after the initialization of the appropriate controller, he setpic database controller and if the controller also needs to be something new.
eleonore19 answered on June 5th 19 at 21:48
You will likely be suitable for storing data in the database. Do not be afraid to use it. Of course you can look at the implementation of the cache when the data is stored a certain time.
If it would be more data, it would be possible to say more precisely.
And according to the model, then it should be the method of getting data (asynchronous), depending on the situation loads the data and saves in database and gives you or just ship them from the database.
Cases many implementations even more.