The code I'm debugging tries to save a contact to Contacts.app via the new CNContacts framework in iOS 9. However it fails and returns this error. The code isn't updating a record but rather it is trying to create a new one. Why and I getting this error?
Error Domain=CNErrorDomain Code=200 "Updated Record Does Not Exist" UserInfo={CNInvalidRecordIdentifiers=( ... ), NSLocalizedDescription=Updated Record Does Not Exist, NSLocalizedFailureReason=The save request failed because it updates a record that does not exist or has already been deleted.}
The code was trying to save a contact with an identifier obtained from a new CNMutableContact
instead of using nil
for the default container.
[saveRequest addContact:mutContact toContainerWithIdentifier:nil];