Converting existing Project to read from Azure Backend

Import Data Model

File >> New >> File >> Data Model. Name it “Activities”.

Ctrl + click >> Show in Finder. Then drag that file onto a text editor such as sublime. You will see basic xml file.

Drag and drop an existing data model file onto the text editor. Copy and paste all the content into your Activities file. Save and close. Your data model should be now updated. Your iOS data model is ready.

Basic Core Stack Class

Create a basic core data stack class with a context, MOC, and PSC.
Make sure the your sql file name, and the data model name are specified.

core data demo

#define DATA_MODEL_FILENAME @”Activities”
#define SQL_FILENAME @”Activities.sqlite”

QSTodoService

Azure should generate a QSTodoService object that does all the reading and writing of data for you.

Unfortunately, it also generates core data code that sits in your AppDelegate. Pull all the core data code out onto your own CoreDataStack class so that AppDelegate is clean.

Then, make these modifications to your QSTodoService:

Use your core stack and its context in QSTodoService’s init method. Commented out code is the original.

ViewController

conform to NSFetchedResultsControllerDelegate protocol

specify what/how you want to fetch for the fetchedResultsController

In the viewDidLoad, make sure you create your QSTodoService because we are going to implement a refresh method that uses it to sync all the data between your app the backend service.

use the fetchedResultsController to get the objects