2010-04-20 9 views

risposta

11

Ho avuto esattamente la stessa domanda. Non sono riuscito a trovare una risposta, quindi ho solo provato a indovinare e controllare il metodo. Il seguente codice sembra funzionare:

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!"); 
} 

Se si seleziona la rubrica, si vedrà un numero di telefono con un'etichetta personalizzata: mylabel

Grazie a: this post

E a: this blog

+0

Per me va bene, grazie mille! – Will

Problemi correlati