diff --git a/CloudCore.xcodeproj/project.pbxproj b/CloudCore.xcodeproj/project.pbxproj
index 6a51003b..f7d7ae93 100755
--- a/CloudCore.xcodeproj/project.pbxproj
+++ b/CloudCore.xcodeproj/project.pbxproj
@@ -917,6 +917,7 @@
D5B2E8B41C3A780C00C0327D /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ APPLICATION_EXTENSION_API_ONLY = YES;
CLANG_ENABLE_MODULES = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
@@ -942,6 +943,7 @@
D5B2E8B51C3A780C00C0327D /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ APPLICATION_EXTENSION_API_ONLY = YES;
CLANG_ENABLE_MODULES = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
diff --git a/CloudCore.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/CloudCore.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
new file mode 100644
index 00000000..18d98100
--- /dev/null
+++ b/CloudCore.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
@@ -0,0 +1,8 @@
+
+
+
+
+ IDEDidComputeMac32BitWarning
+
+
+
diff --git a/Source/Classes/AsynchronousOperation.swift b/Source/Classes/AsynchronousOperation.swift
old mode 100644
new mode 100755
diff --git a/Source/Classes/CloudCore.swift b/Source/Classes/CloudCore.swift
old mode 100644
new mode 100755
index 84421763..261fd216
--- a/Source/Classes/CloudCore.swift
+++ b/Source/Classes/CloudCore.swift
@@ -57,7 +57,11 @@ open class CloudCore {
public static var config = CloudCoreConfig()
/// `Tokens` object, read more at class description. By default variable is loaded from User Defaults.
- public static var tokens = Tokens.loadFromUserDefaults()
+ public static var tokens = Tokens.loadFromUserDefaults() {
+ didSet {
+ tokens.saveToUserDefaults()
+ }
+ }
/// Error and sync actions are reported to that delegate
public static weak var delegate: CloudCoreDelegate? {
@@ -86,7 +90,9 @@ open class CloudCore {
// Subscribe (subscription may be outdated/removed)
#if !os(watchOS)
let subscribeOperation = SubscribeOperation()
- subscribeOperation.errorBlock = { handle(subscriptionError: $0, container: container) }
+ subscribeOperation.errorBlock = {
+ handle(subscriptionError: $0, container: container)
+ }
queue.addOperation(subscribeOperation)
#endif
diff --git a/Source/Classes/ErrorBlockProxy.swift b/Source/Classes/ErrorBlockProxy.swift
old mode 100644
new mode 100755
diff --git a/Source/Classes/Fetch/FetchAndSaveOperation.swift b/Source/Classes/Fetch/FetchAndSaveOperation.swift
old mode 100644
new mode 100755
index 50995fc2..97fb6af2
--- a/Source/Classes/Fetch/FetchAndSaveOperation.swift
+++ b/Source/Classes/Fetch/FetchAndSaveOperation.swift
@@ -68,7 +68,7 @@ public class FetchAndSaveOperation: Operation {
CloudCore.delegate?.didSyncFromCloud()
}
- private func addRecordZoneChangesOperation(recordZoneIDs: [CKRecordZoneID], database: CKDatabase, context: NSManagedObjectContext) {
+ private func addRecordZoneChangesOperation(recordZoneIDs: [CKRecordZone.ID], database: CKDatabase, context: NSManagedObjectContext) {
if recordZoneIDs.isEmpty { return }
let recordZoneChangesOperation = FetchRecordZoneChangesOperation(from: database, recordZoneIDs: recordZoneIDs, tokens: tokens)
@@ -87,14 +87,14 @@ public class FetchAndSaveOperation: Operation {
self.queue.addOperation(deleteOperation)
}
- recordZoneChangesOperation.errorBlock = { zoneID, error in
- self.handle(recordZoneChangesError: error, in: zoneID, database: database, context: context)
+ recordZoneChangesOperation.errorBlock = { recordZoneID, error in
+ self.handle(recordZoneChangesError: error, in: recordZoneID, database: database, context: context)
}
queue.addOperation(recordZoneChangesOperation)
}
- private func handle(recordZoneChangesError: Error, in zoneId: CKRecordZoneID, database: CKDatabase, context: NSManagedObjectContext) {
+ private func handle(recordZoneChangesError: Error, in recordZoneID: CKRecordZone.ID, database: CKDatabase, context: NSManagedObjectContext) {
guard let cloudError = recordZoneChangesError as? CKError else {
errorBlock?(recordZoneChangesError)
return
@@ -111,7 +111,7 @@ public class FetchAndSaveOperation: Operation {
// Our token is expired, we need to refetch everything again
case .changeTokenExpired:
- tokens.tokensByRecordZoneID[zoneId] = nil
+ tokens.tokensByRecordZoneID[recordZoneID] = nil
self.addRecordZoneChangesOperation(recordZoneIDs: [CloudCore.config.zoneID], database: database, context: context)
default: errorBlock?(cloudError)
}
diff --git a/Source/Classes/Fetch/PublicSubscriptions/FetchPublicSubscriptionsOperation.swift b/Source/Classes/Fetch/PublicSubscriptions/FetchPublicSubscriptionsOperation.swift
old mode 100644
new mode 100755
diff --git a/Source/Classes/Fetch/PublicSubscriptions/PublicDatabaseSubscriptions.swift b/Source/Classes/Fetch/PublicSubscriptions/PublicDatabaseSubscriptions.swift
old mode 100644
new mode 100755
diff --git a/Source/Classes/Fetch/SubOperations/DeleteFromCoreDataOperation.swift b/Source/Classes/Fetch/SubOperations/DeleteFromCoreDataOperation.swift
old mode 100644
new mode 100755
index 9e2155ad..9c61d765
--- a/Source/Classes/Fetch/SubOperations/DeleteFromCoreDataOperation.swift
+++ b/Source/Classes/Fetch/SubOperations/DeleteFromCoreDataOperation.swift
@@ -11,10 +11,10 @@ import CloudKit
class DeleteFromCoreDataOperation: Operation {
let parentContext: NSManagedObjectContext
- let recordID: CKRecordID
+ let recordID: CKRecord.ID
var errorBlock: ErrorBlock?
- init(parentContext: NSManagedObjectContext, recordID: CKRecordID) {
+ init(parentContext: NSManagedObjectContext, recordID: CKRecord.ID) {
self.parentContext = parentContext
self.recordID = recordID
diff --git a/Source/Classes/Fetch/SubOperations/FetchRecordZoneChangesOperation.swift b/Source/Classes/Fetch/SubOperations/FetchRecordZoneChangesOperation.swift
old mode 100644
new mode 100755
index 67f0a407..bddaef8d
--- a/Source/Classes/Fetch/SubOperations/FetchRecordZoneChangesOperation.swift
+++ b/Source/Classes/Fetch/SubOperations/FetchRecordZoneChangesOperation.swift
@@ -11,25 +11,25 @@ import CloudKit
class FetchRecordZoneChangesOperation: Operation {
// Set on init
let tokens: Tokens
- let recordZoneIDs: [CKRecordZoneID]
+ let recordZoneIDs: [CKRecordZone.ID]
let database: CKDatabase
//
- var errorBlock: ((CKRecordZoneID, Error) -> Void)?
+ var errorBlock: ((CKRecordZone.ID, Error) -> Void)?
var recordChangedBlock: ((CKRecord) -> Void)?
- var recordWithIDWasDeletedBlock: ((CKRecordID) -> Void)?
+ var recordWithIDWasDeletedBlock: ((CKRecord.ID) -> Void)?
- private let optionsByRecordZoneID: [CKRecordZoneID: CKFetchRecordZoneChangesOptions]
+ private let optionsByRecordZoneID: [CKRecordZone.ID: CKFetchRecordZoneChangesOperation.ZoneOptions]
private let fetchQueue = OperationQueue()
- init(from database: CKDatabase, recordZoneIDs: [CKRecordZoneID], tokens: Tokens) {
+ init(from database: CKDatabase, recordZoneIDs: [CKRecordZone.ID], tokens: Tokens) {
self.tokens = tokens
self.database = database
self.recordZoneIDs = recordZoneIDs
- var optionsByRecordZoneID = [CKRecordZoneID: CKFetchRecordZoneChangesOptions]()
+ var optionsByRecordZoneID = [CKRecordZone.ID: CKFetchRecordZoneChangesOperation.ZoneOptions]()
for zoneID in recordZoneIDs {
- let options = CKFetchRecordZoneChangesOptions()
+ let options = CKFetchRecordZoneChangesOperation.ZoneOptions()
options.previousServerChangeToken = self.tokens.tokensByRecordZoneID[zoneID]
optionsByRecordZoneID[zoneID] = options
}
@@ -49,7 +49,7 @@ class FetchRecordZoneChangesOperation: Operation {
fetchQueue.waitUntilAllOperationsAreFinished()
}
- private func makeFetchOperation(optionsByRecordZoneID: [CKRecordZoneID: CKFetchRecordZoneChangesOptions]) -> CKFetchRecordZoneChangesOperation {
+ private func makeFetchOperation(optionsByRecordZoneID: [CKRecordZone.ID: CKFetchRecordZoneChangesOperation.ZoneOptions]) -> CKFetchRecordZoneChangesOperation {
// Init Fetch Operation
let fetchOperation = CKFetchRecordZoneChangesOperation(recordZoneIDs: recordZoneIDs, optionsByRecordZoneID: optionsByRecordZoneID)
@@ -59,16 +59,12 @@ class FetchRecordZoneChangesOperation: Operation {
fetchOperation.recordWithIDWasDeletedBlock = { recordID, _ in
self.recordWithIDWasDeletedBlock?(recordID)
}
- fetchOperation.recordZoneFetchCompletionBlock = { zoneId, serverChangeToken, clientChangeTokenData, isMore, error in
- self.tokens.tokensByRecordZoneID[zoneId] = serverChangeToken
-
+ fetchOperation.recordZoneChangeTokensUpdatedBlock = { recordZoneID, serverChangeToken, clientChangeTokenData in
+ self.tokens.tokensByRecordZoneID[recordZoneID] = serverChangeToken
+ }
+ fetchOperation.recordZoneFetchCompletionBlock = { recordZoneID, serverChangeToken, clientChangeTokenData, moreComing, error in
if let error = error {
- self.errorBlock?(zoneId, error)
- }
-
- if isMore {
- let moreOperation = self.makeFetchOperation(optionsByRecordZoneID: optionsByRecordZoneID)
- self.fetchQueue.addOperation(moreOperation)
+ self.errorBlock?(recordZoneID, error)
}
}
diff --git a/Source/Classes/Fetch/SubOperations/PurgeLocalDatabaseOperation.swift b/Source/Classes/Fetch/SubOperations/PurgeLocalDatabaseOperation.swift
old mode 100644
new mode 100755
diff --git a/Source/Classes/Fetch/SubOperations/RecordToCoreDataOperation.swift b/Source/Classes/Fetch/SubOperations/RecordToCoreDataOperation.swift
old mode 100644
new mode 100755
diff --git a/Source/Classes/Save/CloudSaveOperationQueue.swift b/Source/Classes/Save/CloudSaveOperationQueue.swift
old mode 100644
new mode 100755
index 583cde4d..3b7ac1b6
--- a/Source/Classes/Save/CloudSaveOperationQueue.swift
+++ b/Source/Classes/Save/CloudSaveOperationQueue.swift
@@ -44,7 +44,7 @@ class CloudSaveOperationQueue: OperationQueue {
}
}
- private func addOperation(recordsToSave: [CKRecord], recordIDsToDelete: [CKRecordID], database: CKDatabase) {
+ private func addOperation(recordsToSave: [CKRecord], recordIDsToDelete: [CKRecord.ID], database: CKDatabase) {
// Modify CKRecord Operation
let modifyOperation = CKModifyRecordsOperation(recordsToSave: recordsToSave, recordIDsToDelete: recordIDsToDelete)
modifyOperation.savePolicy = .changedKeys
@@ -81,7 +81,7 @@ class CloudSaveOperationQueue: OperationQueue {
fileprivate class DatabaseModifyDataSource {
let database: CKDatabase
var save = [CKRecord]()
- var delete = [CKRecordID]()
+ var delete = [CKRecord.ID]()
init(database: CKDatabase) {
self.database = database
diff --git a/Source/Classes/Save/CoreDataListener.swift b/Source/Classes/Save/CoreDataListener.swift
old mode 100644
new mode 100755
diff --git a/Source/Classes/Save/Model/RecordIDWithDatabase.swift b/Source/Classes/Save/Model/RecordIDWithDatabase.swift
old mode 100644
new mode 100755
index b802e464..e133a3ea
--- a/Source/Classes/Save/Model/RecordIDWithDatabase.swift
+++ b/Source/Classes/Save/Model/RecordIDWithDatabase.swift
@@ -9,10 +9,10 @@
import CloudKit
class RecordIDWithDatabase {
- let recordID: CKRecordID
+ let recordID: CKRecord.ID
let database: CKDatabase
- init(_ recordID: CKRecordID, _ database: CKDatabase) {
+ init(_ recordID: CKRecord.ID, _ database: CKDatabase) {
self.recordID = recordID
self.database = database
}
diff --git a/Source/Classes/Save/Model/RecordWithDatabase.swift b/Source/Classes/Save/Model/RecordWithDatabase.swift
old mode 100644
new mode 100755
diff --git a/Source/Classes/Save/ObjectToRecord/CoreDataAttribute.swift b/Source/Classes/Save/ObjectToRecord/CoreDataAttribute.swift
old mode 100644
new mode 100755
diff --git a/Source/Classes/Save/ObjectToRecord/CoreDataRelationship.swift b/Source/Classes/Save/ObjectToRecord/CoreDataRelationship.swift
old mode 100644
new mode 100755
index d2087cc4..069c2862
--- a/Source/Classes/Save/ObjectToRecord/CoreDataRelationship.swift
+++ b/Source/Classes/Save/ObjectToRecord/CoreDataRelationship.swift
@@ -46,7 +46,7 @@ class CoreDataRelationship {
guard let objectsSet = value as? NSSet else { return nil }
- var referenceList = [CKReference]()
+ var referenceList = [CKRecord.Reference]()
for (_, managedObject) in objectsSet.enumerated() {
guard let managedObject = managedObject as? NSManagedObject,
let reference = try makeReference(from: managedObject) else { continue }
@@ -64,8 +64,8 @@ class CoreDataRelationship {
}
}
- private func makeReference(from managedObject: NSManagedObject) throws -> CKReference? {
- let action: CKReferenceAction
+ private func makeReference(from managedObject: NSManagedObject) throws -> CKRecord.Reference? {
+ let action: CKRecord_Reference_Action
if case .some(NSDeleteRule.cascadeDeleteRule) = description.inverseRelationship?.deleteRule {
action = .deleteSelf
} else {
@@ -79,7 +79,7 @@ class CoreDataRelationship {
return nil
}
- return CKReference(record: record, action: action)
+ return CKRecord.Reference(record: record, action: action)
}
}
diff --git a/Source/Classes/Save/ObjectToRecord/ObjectToRecordConverter.swift b/Source/Classes/Save/ObjectToRecord/ObjectToRecordConverter.swift
old mode 100644
new mode 100755
index aa3d9bf8..3ac00c1a
--- a/Source/Classes/Save/ObjectToRecord/ObjectToRecordConverter.swift
+++ b/Source/Classes/Save/ObjectToRecord/ObjectToRecordConverter.swift
@@ -119,7 +119,7 @@ class ObjectToRecordConverter {
}
/// Get appropriate database for modify operations
- private func database(for recordID: CKRecordID, serviceAttributes: ServiceAttributeNames) -> CKDatabase {
+ private func database(for recordID: CKRecord.ID, serviceAttributes: ServiceAttributeNames) -> CKDatabase {
let container = CloudCore.config.container
if serviceAttributes.isPublic { return container.publicCloudDatabase }
diff --git a/Source/Classes/Save/ObjectToRecord/ObjectToRecordOperation.swift b/Source/Classes/Save/ObjectToRecord/ObjectToRecordOperation.swift
old mode 100644
new mode 100755
diff --git a/Source/Classes/Setup Operation/CreateCloudCoreZoneOperation.swift b/Source/Classes/Setup Operation/CreateCloudCoreZoneOperation.swift
old mode 100644
new mode 100755
diff --git a/Source/Classes/Setup Operation/SetupOperation.swift b/Source/Classes/Setup Operation/SetupOperation.swift
old mode 100644
new mode 100755
diff --git a/Source/Classes/Setup Operation/SubscribeOperation.swift b/Source/Classes/Setup Operation/SubscribeOperation.swift
old mode 100644
new mode 100755
index e7b01277..f87cef4c
--- a/Source/Classes/Setup Operation/SubscribeOperation.swift
+++ b/Source/Classes/Setup Operation/SubscribeOperation.swift
@@ -43,7 +43,7 @@ class SubscribeOperation: AsynchronousOperation {
}
private func makeRecordZoneSubscriptionOperation(for database: CKDatabase, id: String) -> CKModifySubscriptionsOperation {
- let notificationInfo = CKNotificationInfo()
+ let notificationInfo = CKSubscription.NotificationInfo()
notificationInfo.shouldSendContentAvailable = true
let subscription = CKRecordZoneSubscription(zoneID: CloudCore.config.zoneID, subscriptionID: id)
diff --git a/Source/Classes/Setup Operation/UploadAllLocalDataOperation.swift b/Source/Classes/Setup Operation/UploadAllLocalDataOperation.swift
old mode 100644
new mode 100755
diff --git a/Source/Classes/Test.xcdatamodeld/Test.xcdatamodel/contents b/Source/Classes/Test.xcdatamodeld/Test.xcdatamodel/contents
new file mode 100644
index 00000000..e272dd53
--- /dev/null
+++ b/Source/Classes/Test.xcdatamodeld/Test.xcdatamodel/contents
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/Source/Enum/CloudCoreError.swift b/Source/Enum/CloudCoreError.swift
old mode 100644
new mode 100755
diff --git a/Source/Enum/FetchResult.swift b/Source/Enum/FetchResult.swift
old mode 100644
new mode 100755
diff --git a/Source/Enum/Module.swift b/Source/Enum/Module.swift
old mode 100644
new mode 100755
diff --git a/Source/Extensions/CKRecordID.swift b/Source/Extensions/CKRecordID.swift
old mode 100644
new mode 100755
index da63c85a..0fbac032
--- a/Source/Extensions/CKRecordID.swift
+++ b/Source/Extensions/CKRecordID.swift
@@ -8,17 +8,17 @@
import CloudKit
-extension CKRecordID {
+extension CKRecord.ID {
private static let separator = "|"
/// Init from encoded string
///
/// - Parameter encodedString: format: `recordName|ownerName`
convenience init?(encodedString: String) {
- let separated = encodedString.components(separatedBy: CKRecordID.separator)
+ let separated = encodedString.components(separatedBy: CKRecord.ID.separator)
if separated.count == 2 {
- let zoneID = CKRecordZoneID(zoneName: CloudCore.config.zoneID.zoneName, ownerName: separated[1])
+ let zoneID = CKRecordZone.ID(zoneName: CloudCore.config.zoneID.zoneName, ownerName: separated[1])
self.init(recordName: separated[0], zoneID: zoneID)
} else {
return nil
@@ -27,6 +27,6 @@ extension CKRecordID {
/// Encoded string in format: `recordName|ownerName`
var encodedString: String {
- return recordName + CKRecordID.separator + zoneID.ownerName
+ return recordName + CKRecord.ID.separator + zoneID.ownerName
}
}
diff --git a/Source/Extensions/NSEntityDescription.swift b/Source/Extensions/NSEntityDescription.swift
old mode 100644
new mode 100755
diff --git a/Source/Extensions/NSManagedObject.swift b/Source/Extensions/NSManagedObject.swift
old mode 100644
new mode 100755
index 757781ed..a37b11c7
--- a/Source/Extensions/NSManagedObject.swift
+++ b/Source/Extensions/NSManagedObject.swift
@@ -35,8 +35,9 @@ extension NSManagedObject {
guard let serviceAttributeNames = self.entity.serviceAttributeNames else {
throw CloudCoreError.missingServiceAttributes(entityName: self.entity.name)
}
-
- let record = CKRecord(recordType: entityName, zoneID: CloudCore.config.zoneID)
+
+ let recordID = CKRecord.ID(recordName: entityName, zoneID: CloudCore.config.zoneID)
+ let record = CKRecord(recordType: entityName, recordID: recordID)
self.setValue(record.encdodedSystemFields, forKey: serviceAttributeNames.recordData)
self.setValue(record.recordID.encodedString, forKey: serviceAttributeNames.recordID)
diff --git a/Source/Extensions/NSManagedObjectModel.swift b/Source/Extensions/NSManagedObjectModel.swift
old mode 100644
new mode 100755
diff --git a/Source/Model/CKRecord.swift b/Source/Model/CKRecord.swift
old mode 100644
new mode 100755
diff --git a/Source/Model/CloudCoreConfig.swift b/Source/Model/CloudCoreConfig.swift
old mode 100644
new mode 100755
index 582fc48e..fa61ebd8
--- a/Source/Model/CloudCoreConfig.swift
+++ b/Source/Model/CloudCoreConfig.swift
@@ -25,6 +25,10 @@ import CloudKit
*/
public struct CloudCoreConfig {
+ // MARK: - Init
+
+ public init() { }
+
// MARK: CloudKit
/// The CKContainer to store CoreData. Set this to a custom container to
@@ -37,15 +41,15 @@ public struct CloudCoreConfig {
/// RecordZone inside private database to store CoreData.
///
/// Default value is `CloudCore`
- public var zoneID = CKRecordZoneID(zoneName: "CloudCore", ownerName: CKCurrentUserDefaultName)
- let subscriptionIDForPrivateDB = "CloudCorePrivate"
- let subscriptionIDForSharedDB = "CloudCoreShared"
+ public var zoneID = CKRecordZone.ID(zoneName: "CloudCore", ownerName: CKCurrentUserDefaultName)
+ public var subscriptionIDForPrivateDB = "CloudCorePrivate"
+ public var subscriptionIDForSharedDB = "CloudCoreShared"
/// subscriptionID's prefix for custom CKSubscription in public databases
- var publicSubscriptionIDPrefix = "CloudCore-"
+ public var publicSubscriptionIDPrefix = "CloudCore-"
// MARK: Core Data
- let contextName = "CloudCoreFetchAndSave"
+ public var contextName = "CloudCoreFetchAndSave"
/// Default entity's attribute name for *Record ID* if User Info is not specified.
///
diff --git a/Source/Model/CloudKitAttribute.swift b/Source/Model/CloudKitAttribute.swift
old mode 100644
new mode 100755
index 805b0dc1..da26c45b
--- a/Source/Model/CloudKitAttribute.swift
+++ b/Source/Model/CloudKitAttribute.swift
@@ -30,8 +30,8 @@ class CloudKitAttribute {
func makeCoreDataValue() throws -> Any? {
switch value {
- case let reference as CKReference: return try findManagedObject(for: reference.recordID)
- case let references as [CKReference]:
+ case let reference as CKRecord.Reference: return try findManagedObject(for: reference.recordID)
+ case let references as [CKRecord.Reference]:
let managedObjects = NSMutableSet()
for ref in references {
guard let foundObject = try findManagedObject(for: ref.recordID) else { continue }
@@ -45,7 +45,7 @@ class CloudKitAttribute {
}
}
- private func findManagedObject(for recordID: CKRecordID) throws -> NSManagedObject? {
+ private func findManagedObject(for recordID: CKRecord.ID) throws -> NSManagedObject? {
let targetEntityName = try findTargetEntityName()
let fetchRequest = NSFetchRequest(entityName: targetEntityName)
diff --git a/Source/Model/ServiceAttributeName.swift b/Source/Model/ServiceAttributeName.swift
old mode 100644
new mode 100755
diff --git a/Source/Model/Tokens.swift b/Source/Model/Tokens.swift
old mode 100644
new mode 100755
index a91ab8a8..4d93b918
--- a/Source/Model/Tokens.swift
+++ b/Source/Model/Tokens.swift
@@ -29,7 +29,7 @@ import CloudKit
*/
open class Tokens: NSObject, NSCoding {
- var tokensByRecordZoneID = [CKRecordZoneID: CKServerChangeToken]()
+ var tokensByRecordZoneID = [CKRecordZone.ID: CKServerChangeToken]()
private struct ArchiverKey {
static let tokensByRecordZoneID = "tokensByRecordZoneID"
@@ -45,7 +45,7 @@ open class Tokens: NSObject, NSCoding {
/// Load saved Tokens from UserDefaults. Key is used from `CloudCoreConfig.userDefaultsKeyTokens`
///
/// - Returns: previously saved `Token` object, if tokens weren't saved before newly initialized `Tokens` object will be returned
- open static func loadFromUserDefaults() -> Tokens {
+ public static func loadFromUserDefaults() -> Tokens {
guard let tokensData = UserDefaults.standard.data(forKey: CloudCore.config.userDefaultsKeyTokens),
let tokens = NSKeyedUnarchiver.unarchiveObject(with: tokensData) as? Tokens else {
return Tokens()
@@ -56,16 +56,16 @@ open class Tokens: NSObject, NSCoding {
/// Save tokens to UserDefaults and synchronize. Key is used from `CloudCoreConfig.userDefaultsKeyTokens`
open func saveToUserDefaults() {
+
let tokensData = NSKeyedArchiver.archivedData(withRootObject: self)
UserDefaults.standard.set(tokensData, forKey: CloudCore.config.userDefaultsKeyTokens)
- UserDefaults.standard.synchronize()
}
// MARK: NSCoding
/// Returns an object initialized from data in a given unarchiver.
public required init?(coder aDecoder: NSCoder) {
- if let decodedTokens = aDecoder.decodeObject(forKey: ArchiverKey.tokensByRecordZoneID) as? [CKRecordZoneID: CKServerChangeToken] {
+ if let decodedTokens = aDecoder.decodeObject(forKey: ArchiverKey.tokensByRecordZoneID) as? [CKRecordZone.ID: CKServerChangeToken] {
self.tokensByRecordZoneID = decodedTokens
} else {
return nil
diff --git a/Source/Protocols/CloudCoreDelegate.swift b/Source/Protocols/CloudCoreDelegate.swift
old mode 100644
new mode 100755