Sync CoreData with CloudKit
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
JLCloudKitSync.xcodeproj
JLCloudKitSync
JLCloudKitSyncTests
JLCloudKitSyncTestsHost
.gitignore
JLCloudkitSync.podspec
LICENSE
README.md

README.md

JLCloudKitSync

Sync CoreData with CloudKit

A dirty implementation to sync core data with CloudKit. Still under heavy development.

API

Setup

let syncer = JLCloudKitSync(context: context)
syncer.setupWorkZone("Your Zone Name Here", completionHandler: { error -> Void in
  // All things start from here
})

Discovery

syncer.discoverEntities(recordType: String) { (exists, error) -> Void in
	if exists {
		// There is already data in the cloud
	} else {
		// A fresh start!
	}
}

First Time Sync

// Data in the cloud will be replace with local one
syncer.performFullSync(JLCloudKitFullSyncPolicy.ReplaceDataOnCloudKit)
	
// Or, replace the local data with ones in cloud
syncer.performFullSync(JLCloudKitFullSyncPolicy.ReplaceDataOnLocal)

Normal Sync

// Sync will be automatically triggered after context is saved.
// Or you can perform a sync in any time by performSync()
syncer.performSync()

Notifications

// Sync starts with a begin notification
public let JLCloudKitSyncWillBeginNotification = "JLCloudKitSyncWillBeginNotification"
// and ends with a end notification
public let JLCloudKitSyncDidEndNotification = "JLCloudKitSyncDidEndNotification"