adding a new number to existing ABRecord in ABAddressBook - iPhone
<p>I am trying to update the content of an existing contact in the addressbook through my application but without the need for a UI. The scenario is like this:</p>

<p>1 The user enters a number and a name
2 The application checks if that name is in the contacts list
3 if it is then it checks if the number is one of the contacts for that name
4 If not it adds it to that name</p>

<p>I have managed to achieve steps 1-3 but i could not find a way to do 4. Can any one help?</p>

<p>Below if what my code looks like</p>

<pre><code>...
CFIndex lTotalContactsCount = ABAddressBookGetPersonCount(lAddressBook);
NSArray *people = (NSArray *)ABAddressBookCopyArrayOfAllPeople(lAddressBook );

for (CFIndex i = 0; i &lt; lTotalContactsCount; i++)
{
    ABRecordRef lRef = (ABRecordRef)[people objectAtIndex:i];   

    ...
    // if names match
    {
        ABMutableMultiValueRef lPhoneNumbers = ABRecordCopyValue(lRef, kABPersonPhoneProperty);
        CFIndex lContactPhoneNumberCount = ABMultiValueGetCount(lPhoneNumbers);
        ABRecordID contactID = ABRecordGetRecordID(lRef);

        ...
         // if numbers dont match
        {
                   // THIS BIT IS NOT WOKRING
            CFErrorRef error = NULL; 

            ABMutableMultiValueRef multiPhone = ABMultiValueCreateMutable(kABMultiStringPropertyType);
            ABMultiValueAddValueAndLabel(multiPhone, number, (CFStringRef)@"Duplicate", NULL);

        //  ABRecordSetValue(newPerson, kABPersonFirstNameProperty, name, &amp;error);

            //add the number to the contact
            ABRecordSetValue(lRef, kABPersonPhoneProperty, multiPhone,nil);
        //  ABAddressBookAddRecord(lAddressBook, lRef, &amp;error);
            ABAddressBookSave(lAddressBook, &amp;error);
        }

        if( firstName )
            CFRelease(firstName);
        if( lastName )
            CFRelease(lastName);
        if( lPhoneNumbers )
            CFRelease(lPhoneNumbers);

        // no need to search other entries
        if(numberExists)
            break;
    }
</code></pre>
