Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the most effective workflow for this iOS app?

I have an app that requires internet for syncing a webservice to a local core data db. Then a local db fetch is used to populate different objects for a MapView and a TableView in a tabbarcontroller. Im looking at these 2 scenarios:

AppFlowLogic

The main advantage of "A" is that I dont have to preload the app with a database, although its a small db (about 100 records). The problem is that it gets convoluted. If there is no internet connection, in MapView, the user sees a map but the refreshButton is disabled. So thats not a problem. But the user can still go to the tableview and he will see an empty table.

The main advantage of "B" is that with a preloaded db, the app will always have a data source ready for plotting and listing. I dont really know how to preload the app with a db though.

I kind of want to go the first route, "A". My main question is, since right now I disabled the refreshButton on MapView so that it only works once the data is gotten from the web...that sortedArray is empty on launch. So if the user goes to the TableVC it will be empty. As it stands, the user must first tap the refresh button before going to the tableview.

What is the most effective way to deal with this?

like image 748
marciokoko Avatar asked Mar 08 '13 15:03

marciokoko


1 Answers

If the 100 records are static enough that you can ship a default set of records with the app, that would be the best solution. The user, with or without internet, gets a populated tableview.

Ship your records as a plist in your app's bundle. On first launch, open the plist and add each entry as a new object into core data. This type of "seeding" happens very quickly. Just create a collection (array, dictionary) for the plist, then enumerate through, mapping it to your managedObject's attributes.

There's code that shows you how to do this in the WWDC 2012 video iCloud and Core Data (just ignore the iCloud part).

Then if there's a connection after the seeding, you can sync data, which would update/replace/etc the pre-populated data.

like image 188
Jason C. Howlin Avatar answered Oct 07 '22 02:10

Jason C. Howlin