0
我需要遷移記錄,因爲'CKFetchRecordChangesOperation'不適用於默認的記錄。我應該逐一遷移還是有辦法自動執行?如何將ckrecords從默認區域遷移到自定義區域?
我需要遷移記錄,因爲'CKFetchRecordChangesOperation'不適用於默認的記錄。我應該逐一遷移還是有辦法自動執行?如何將ckrecords從默認區域遷移到自定義區域?
是的,它需要逐一完成。你需要從舊區域中的所有提取,然後創建新的自定義區域一個新的像這樣:
func newRecord(from record: CKRecord, newZone: CKRecordZone) -> CKRecord {
let recordID = CKRecordID(recordName: record.recordID.recordName, zoneID: newZone.zoneID)
let newRecord = CKRecord(recordType: "Goal", recordID: recordID)
newRecord["startDate"] = record["startDate"]
newRecord["endDate"] = record["endDate"]
newRecord["hours"] = record["hours"]
return newRecord
}
並保存到CKDatabase
。