Both appleIDs(create and modify/save) sign in iCloud.
I use the following code to modify and save records:
self.containerIdentifier).publicCloudDatabase
database.fetch(withRecordID: CKRecord.ID(recordName:groupID), completionHandler: { record, error in
if error == nil && record != nil {
if let iDs : [String] = record!.object(forKey: "memberIDs") as? Array {
if iDs.count < self.maxMemberCount {
if let mems: [String] = record!.object(forKey: "memberNames") as? Array {
if !(mems as NSArray).contains(name) {
var members = mems
members.append(name)
record!.setObject(members as CKRecordValue, forKey: "memberNames")
var iDs : [String] = record!.object(forKey: "memberIDs") as! Array
iDs.append(self.myMemberID)
record!.setObject(iDs as CKRecordValue, forKey:"memberIDs")
database.save(record!, completionHandler: { record, error in
if error == nil {
} else {
completion(error as NSError?)
dPrint("Error : \(String(describing: error))")
}
})
}else{
let DBError : NSError = NSError(domain: "DBError", code: 89, userInfo: ["localizedDescription": NSLocalizedString("Your nickname already used.", comment:"")])
completion(DBError)
print("change your nickname")
}
}else{
print("group DB error")
let DBError : NSError = NSError(domain: "DBError", code: 88, userInfo: ["localizedDescription": NSLocalizedString("Please try later.", comment:"")])
completion(DBError)
}
}
}else{
print("Error : \(String(describing: error))")
}
})
I received the following error message:
?Error saving records: <CKError 0x600000bbe970: "Service Unavailable" (6/NSCocoaErrorDomain:4099); "Error connecting to CloudKit daemon. This could happen for many reasons, for example a daemon exit, a device reboot, a race with the connection inactivity monitor, invalid entitlements, and more. Check the logs around this time to investigate the cause of this error."; Retry after 5.0 seconds>
baseNSError@0 NSError domain: "CKErrorDomain" - code: 6
_userInfo __NSDictionaryI * 4 key/value pairs 0x000060000349e300
[0] (null) "NSLocalizedDescription" : "Error connecting to CloudKit daemon. This could happen for many reasons, for example a daemon exit, a device reboot, a race with the connection inactivity monitor, invalid entitlements, and more. Check the logs around this time to investigate the cause of this error."
key __NSCFConstantString * "NSLocalizedDescription" 0x00000001117155a0
value __NSCFConstantString * "Error connecting to CloudKit daemon. This could happen for many reasons, for example a daemon exit, a device reboot, a race with the connection inactivity monitor, invalid entitlements, and more. Check the logs around this time to investigate the cause of this error." 0x000000011057e700
[1] (null) "CKRetryAfter" : Int32(5)
key __NSCFConstantString * "CKRetryAfter" 0x000000011057c680
value NSConstantIntegerNumber? Int32(5) 0x00000001105c2ed0
[2] (null) "CKErrorDescription" : "Error connecting to CloudKit daemon. This could happen for many reasons, for example a daemon exit, a device reboot, a race with the connection inactivity monitor, invalid entitlements, and more. Check the logs around this time to investigate the cause of this error."
key __NSCFConstantString * "CKErrorDescription" 0x0000000110568d00
value __NSCFConstantString * "Error connecting to CloudKit daemon. This could happen for many reasons, for example a daemon exit, a device reboot, a race with the connection inactivity monitor, invalid entitlements, and more. Check the logs around this time to investigate the cause of this error." 0x000000011057e700
[3] (null) "NSUnderlyingError" : domain: "NSCocoaErrorDomain" - code: 4099
key __NSCFConstantString * "NSUnderlyingError" 0x0000000111715540
value NSError? domain: "NSCocoaErrorDomain" - code: 4099 0x00006000016cc300