In AddressBook on device I have a record linked with Facebook contact record. I fetch it into CNContact with CNContactFetchRequest with:
contactFetchRequest.mutableObjects = true
contactFetchRequest.unifyResults = false
After getting, I modify it, then I trying to update it with:
let store = CNContactStore()
let saveRequest = CNSaveRequest()
if contact != nil {
mutableContact = contact!.mutableCopy() as! CNMutableContact
saveRequest.updateContact( mutableContact )
} else {
mutableContact = CNMutableContact()
saveRequest.addContact( mutableContact, toContainerWithIdentifier:nil )
}
// Modify mutableContact
mutableContact.jobTitle = "Worker";
do {
// Will fails with error
try store.executeSaveRequest(saveRequest)
} catch let error as NSError {
BCRLog(error)
self.isFailed = true
} catch {
self.isFailed = true
}
On execute executeSaveRequest, I caught an error:
NSError with domain:CNErrorDomain, code:500 (witch is CNErrorCodePolicyViolation), _userInfo: {"NSUnderlyingError" : {"ABAddressBookErrorDomain" - code 0}} witch is kABOperationNotPermittedByStoreError
The question: Is it possible to modify linked contact (not unified), and if it is, what i do wrong?
If I modifying not linked contact - all OK!