Question

I'm starting an app in iOS which will use a SQLite database.

I would like to reuse the code of this app for others in future.

I would like to make first a view associate to a ViewModel.

I will use a repository for my data. First, it will be generate, and after, data from SQLite database.

Then, when I'll use the database, just change some stuff in my ViewModel and all will work good...

I don't know if you see what I mean...

Do you know some good practices to do this? Tutorials, explanation, or anything else interesting?

EDIT:

I would like to follow this way:

  • Repository can be database data or random generated data for testing before I have the database...

  • ViewModel is the "model of myt view" which set all objects of my view with the data fetched in my Repository...

I understand the idea, but I don't know how to proceed to do this and I found nothing about the method... Maybe it's not a good way ?

If you have any suggestion, please let me know ;) Thank you!

Was it helpful?

Solution

Make an object class for the interaction with the sqlite, Preferred will be a singleton class which could also be used as intermediary storing class.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top