删除号码 phone 联系人 - Swift 3 - 4

Delete number phone Contact - Swift 3 - 4

我要删除联系方式,我用ContactsUI

//only do this to the first contact matching our criteria
   guard let contact = contacts?.first else{
   return
    }
   let editContact = contact.mutableCopy() as! CNMutableContact

   editContact.phoneNumbers[1]..... ? 

在editContact.phoneNumbers[1]..我想消除那个位置的数字

编辑一下,我是这样编辑的。而且效果很好

editContact.phoneNumbers[1] =  CNLabeledValue(label: "home",
                                                          value: CNPhoneNumber(stringValue: "1234567"))

但是如何消除它

phoneNumbers 是一个数组。像删除任何其他数组值一样删除所需的元素:

let editContact = contact.mutableCopy() as! CNMutableContact
editContact.phoneNumbers.remove(at: 1)

当然,我会确保至少有 2 phone 个数字,然后再这样做。