2010-04-20 3 views

Antwort

11

Ich hatte genau diese Frage. Ich konnte keine Antwort finden, also habe ich einfach die Rate- und Check-Methode ausprobiert. Der folgende Code scheint zu funktionieren:

CFErrorRef error = NULL; 
ABAddressBookRef iPhoneAddressBook = ABAddressBookCreate(); 
ABRecordRef newPerson = ABPersonCreate(); 
ABRecordSetValue(newPerson, kABPersonFirstNameProperty, @"Jane", &error); 
ABRecordSetValue(newPerson, kABPersonLastNameProperty, @"Smith", &error); 

const CFStringRef customLabel = CFSTR("mylabel"); 

//phone 
ABMutableMultiValueRef multiPhone = ABMultiValueCreateMutable(kABMultiStringPropertyType); 
ABMultiValueAddValueAndLabel(multiPhone, @"1-444-444-444", kABPersonPhoneMainLabel, NULL); 
ABMultiValueAddValueAndLabel(multiPhone, @"1-333-333-333", kABPersonPhoneMobileLabel, NULL);    
ABMultiValueAddValueAndLabel(multiPhone, @"1-666-666-666", kABOtherLabel, NULL);   
ABMultiValueAddValueAndLabel(multiPhone, @"1-555-555-555", customLabel, NULL); 
ABRecordSetValue(newPerson, kABPersonPhoneProperty, multiPhone,nil); 
CFRelease(multiPhone); 

ABAddressBookAddRecord(iPhoneAddressBook, newPerson, &error); 
ABAddressBookSave(iPhoneAddressBook, &error); 

if (error != NULL) 
{ 
    NSLog(@"Error!"); 
} 

Wenn Sie das Adressbuch überprüfen, werden Sie eine Telefonnummer mit einem individuell gestalteten Etikett sehen: mylabel

Dank: this post

Und: this blog

+0

Es funktioniert gut für mich, vielen Dank! – Will

Verwandte Themen