0

I want to delete a contact from addressBook. I use this code to delete a contact from contact list of device.

var recordId = ABRecordID(contact.contactId)
var newContact: ABRecordRef! = ABAddressBookGetPersonWithRecordID(self.add?.adbk, recordId).takeRetainedValue()

var success: Bool = false

var error: Unmanaged<CFErrorRef>? = nil

success = ABAddressBookRemoveRecord(self.add?.adbk, newContact, &error)

println("Adbk addRecord successful? \(success) error \(error)")

createAddressBook()

if success {
    success = ABAddressBookSave(self.add?.adbk, &error)

    println("Adbk save successful? \(success) error \(error)")
}

But I don't understand why I get BAD_ACCESS error in run time. I stop the program and run again, the contact deleted successfuly. Also in my code the SIGKill signal is written. What should I have to do?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
user2056962
  • 85
  • 1
  • 1
  • 7

0 Answers0