Skip to content

Instantly share code, notes, and snippets.

@roymckenzie
Last active January 27, 2017 22:00
Show Gist options
  • Save roymckenzie/f3e0c96f6293db2eff10f6a0b982993d to your computer and use it in GitHub Desktop.
Save roymckenzie/f3e0c96f6293db2eff10f6a0b982993d to your computer and use it in GitHub Desktop.
Protocol for Realm Objects that I want to sync with CloudKit
protocol CloudKitSyncable {
var id: String { get }
var recordID: CKRecordID { get }
var synced: Date? { get }
var modified: Date { get }
var deleted: Date? { get }
var record: CKRecord { get }
var recordChangeTag: String? { get }
var recordOwnerName: String? { get }
}
final class RealmObject: Object {
// All your object specific properties
//
// CloudKitSyncable
dynamic var id: String = UUID().uuidString
dynamic var synced: Date? = nil
dynamic var modified: Date = Date()
dynamic var deleted: Date? = nil
dynamic var recordChangeTag: String? = nil
dynamic var recordOwnerName: String? = CKOwnerDefaultName
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment