The AddressBook Framework offers a great method for initializing an ABPerson with a vCard, by using the initWithVCardRepresentation: method.
What I want to do is update a contact with a certain vCard. I can’t use initWithVCardRepresentation: because this will give me a new ABPerson object with a new uniqueId and I want to keep the uniqueId in between these changes.
What’s an easy way to go about doing something like this?
Thanks!
initWithVCardRepresentationis still the slickest way to turn your vCard into anABPerson.Just use the results of it to find the matching person in your Address Book and then iterate over the vCard properties, placing them into the existing record. The save at the end will harden your changes.
The following example assumes that the unique “keys” will be
last-name,first-name. You can modify the search element if you want to include companies where no name is listed or whatever, or you could change the iteration scheme by getting [AddressBook people], and then iterating over the people and using only those records where the key-value pairs match to your satisfaction.