Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8249243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:28:13+00:00 2026-06-07T23:28:13+00:00

The AddressBook Framework offers a great method for initializing an ABPerson with a vCard,

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T23:28:16+00:00Added an answer on June 7, 2026 at 11:28 pm

    initWithVCardRepresentation is still the slickest way to turn your vCard into an ABPerson.

    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.

    - (void)initOrUpdateVCardData:(NSData*)newVCardData {
        ABPerson* newVCard = [[ABPerson alloc] initWithVCardRepresentation:newVCardData];
        ABSearchEleemnt* lastNameSearchElement
          = [ABPerson searchElementForProperty:kABLastNameProperty
                                         label:nil
                                           key:nil
                                         value:[newVCard valueForProperty:kABLastNameProperty]
                                    comparison:kABEqualCaseInsensitive];
        ABSearchEleemnt* firstNameSearchElement
          = [ABPerson searchElementForProperty:kABFirstNameProperty
                                         label:nil
                                           key:nil
                                         value:[newVCard valueForProperty:kABFirstNameProperty]
                                    comparison:kABEqualCaseInsensitive];
        NSArray* searchElements
          = [NSArray arrayWithObjects:lastNameSearchElement, firstNameSearchElement, nil];
        ABSearchElement* searchCriteria
          = [ABSearchElement searchElementForConjunction:kABSearchAnd children:searchElements];
        AddressBook* myAddressBook = [AddressBook sharedAddressBook];
        NSArray* matchingPersons = [myAddressBook recordsMatchingSearchElement:searchCriteria];
        if (matchingPersons.count == 0)
        {
            [myAddressBook addRecord:newVCard];
        }
        else if (matchingPersons.count > 1)
        {
            // decide how to handle error yourself here: return, or resolve conflict, or whatever
        }
        else
        {
            ABRecord* existingPerson = matchingPersons.lastObject;
            for (NSString* property in [ABPerson properties])   // i.e. *all* potential properties
            {
                // if the property doesn't exist in the address book, value will be nil
                id value = [newVCard valueForProperty:property];
                if (value)
                {
                    NSError* error;
                    if (![existingPerson setValue:value forProperty:property error:&error] || error)
                        // handle error
                }
            }
            // newVCard with it's new unique-id will now be thrown away
        }
        [myAddressBook save];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to programmatically add a new group to the iPhone contact using AddressBook framework?
Using the built-in Address Book framework for iPhone, how can I save a specific
I need to add a contact in AddressBook of IPhone from the VCard i
I'm able to retrieve contact's phone number from the device using Address Book framework
I have added the framework: #import AddressBook/ABAddressBook.h #import AddressBookUI/AddressBookUI.h I want to get the
The AddressBook framework provides ABPersonCopyImageData for getting the contact image for each address book
Using the 'AddressBook.framework' is it possible to filter out all companies (i.e. just people).
Can someone show an example of this in objective-c? I have the addressbook framework
I have been using the AddressBook api of the iPhone for some time now.
I am currently using Java ME to extract Addressbook (ContactList) fields in a device

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.