私のアプリケーションには奇妙なエラーが発生し、回避策や修正が見つかりません。何らかの理由で、ソーシャルプロファイル(Facebook、Twitterなど)で統一されていない連絡先に住所を保存することができます。私はFacebookやTwitterので統一され、私の連絡先のアドレスを追加しようとすると、しかし、私は奇妙なセーブエラーが表示されます。ここでは連絡先の連絡先をユニファイドコンタクトに保存すると、(CNErrorDomain error 500)
The operation couldn’t be completed. (CNErrorDomain error 500.)
は、私が使用しているコードの一部です:
if mutableContact.isKeyAvailable(CNContactPostalAddressesKey) {
var postalAddresses = [CNLabeledValue<CNPostalAddress>]()
for address in self.contactAddresses {
let postalAddress: CNLabeledValue<CNPostalAddress> = CNLabeledValue(label: CNLabelOther, value: address)
postalAddresses.append(postalAddress)
}
mutableContact.postalAddresses = postalAddresses
}
let saveRequest = CNSaveRequest()
if isNewContact {
saveRequest.add(mutableContact, toContainerWithIdentifier: nil)
} else {
saveRequest.update(mutableContact)
}
do {
try contactStore.execute(saveRequest)
} catch let error as NSError {
print(error.localizedDescription)
let alertController = UIAlertController(title: "Failed to save/update contact!", message: "Unfortunatly, the app couldn't add or make modifications to your contact. Please try again or use the Contacts app to preform changes.", preferredStyle: .alert)
let cancelAction = UIAlertAction(title: "Okay", style: .cancel) {
action in
self.dismiss(animated: true, completion: nil)
}
alertController.addAction(cancelAction)
self.present(alertController, animated: true, completion: nil)
}
この問題は修正しましたか? – Rendel
@RendelはまだAppleからの回答を得ていません – Harish