I have a list of contacts in table view cell whenever I click a cell which is an existing contact I want to add or update address in that existing contact.
var selectedContact: Contact!
var updateContact = CNContact()Contact! is a model
Code for Updating Contact Address
func AddMultipleLocations(){
var contact = CNMutableContact()
contact = selectedAddress.mutableCopy() as! CNMutableContact
// error Value of type Contact has no member mutableCopy
contact.postalAddresses.append(CNLabeledValue(label: CNLabelHome, value: homeAddress))
print(homeAddress)
do {
let saveRequest = CNSaveRequest()
saveRequest.update(contact)
let contactstore = CNContactStore()
try contactstore.execute(saveRequest)
self.showToast(message: "Contact Updated ", font: .systemFont(ofSize: 12.0))
} catch let error {
print(error.localizedDescription)
self.showToast(message: error.localizedDescription, font: .systemFont(ofSize: 12.0))}