TestsTested | ✓ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Dec 2014 |
Maintained by Delisa Mason.
A simple, customizable service for updating Core Data models. It uses ObjectiveRecord for mapping data in dictionary format to a Core Data entity's properties.
After fetching new data with which to update and insert new model instances, invoke the synchronization service to reconcile the new data with a Core Data entity.
#import <SimpleSyncService/SimpleSyncService.h>
// (Perform some fetching task, format data as an array
// of dictionaries...)
[SimpleSyncService synchronizeData:arrayOfUpdatedModelData
withEntityName:modelEntityName
inContext:managedObjectContext
withIdentifierNamed:@"remoteID"];
When the property key in the data differs from the model property name, it can be specified like so:
[SimpleSyncService synchronizeData:arrayOfUpdatedModelData
withEntityName:modelEntityName
inContext:managedObjectContext
withDataIdentifierNamed:@"email"
andModelIdentifierNamed:@"emailAddress"];
The identifier properties are used to determine whether an existing record should be updated or a new record should be inserted.
Format data fetching tasks as synchronization service adapters which are invoked on a background queue at customizable intervals. The basic flow is as follows:
Subclass DMMSyncServiceAdapter
and write your fetching code in fetchDataWithCompletion:
, remembering to invoke the SyncCompletionBlock
when done fetching and formatting data.
Initialize your adapters with initWithInterval:entityName:modelIDKey:
using the interval at which they should be run and the entity name of the model to upate. The modelIDKey
is used to determine whether new data should update an existing record or be inserted as a new one.
Create a new SimpleSyncService
instance with your adapters and preferred operation queue using initWithAdapters:useQueue:
Start the service with start
Stop the service at any time using stop
An example of this flow is included in the sample project in this repository.
Include pod 'SimpleSyncService'
in your Podfile
Contributions welcome, SimpleSyncService is testing using Kiwi.