2016-11-12 19 views
5

私のアプリケーションには奇妙なエラーが発生し、回避策や修正が見つかりません。何らかの理由で、ソーシャルプロファイル(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) 
    } 
+0

この問題は修正しましたか? – Rendel

+0

@RendelはまだAppleからの回答を得ていません – Harish

答えて

1

だから、私はAppleからの返答を得ており、この動作は意図されています。開発者はこのポリシー違反を検出し、新しい連絡先を作成してから2つの連絡先をリンクする必要があります。

+1

Gah。どのような恐ろしい解決策。 :) –

+1

@DuncanBabbage私はそれが私にバグのように見えることを知っている – Harish

関連する問題