March 29, 2014 by Blake Lucchesi

Data Objects, Sync and ViewControllers

At SendHub we use the following architecture for storing and retrieving data to be presented on the screens throughout our app.

When retrieving data from our server for local persistence we do the following:

When retrieving data to present in our table and collection views we use the following setup:

To date, this has worked quite well. We’re able to perform all of the REST API retrieval and database inserts in the background. We don’t have issues with differing contexts (looking at you Core Data). Using SQLite directly has even been a plus because we have the power to run JOINs in our queries, and all that jazz.

The shortcoming that we are starting to experience is that when we update our UI based on the notifications of new data, we need to be smarter about which items in our table data have changed. i.e. We can do better than calling [self.tableView reloadData] in the view controller, like calling insertRowsAtIndexPath:withRowAnimation or reloadRowsAtIndexPaths:withRowAnimation

I’m still trying to evaluate some options, but I just recently saw a really cool library called YapDatabase which seems to have changesets sorted out quite well. I’ll be testing it out later this week and will report back with some thoughts and findings.

comments powered by Disqus