2011-03-22 9 views

Respuesta

28

Aquí hay un pequeño ejemplo:

CFErrorRef error = NULL; 
NSLog(@"%@", [self description]); 
ABAddressBookRef iPhoneAddressBook = ABAddressBookCreate(); 

ABRecordRef newPerson = ABPersonCreate(); 

ABRecordSetValue(newPerson, kABPersonFirstNameProperty, people.firstname, &error); 
ABRecordSetValue(newPerson, kABPersonLastNameProperty, people.lastname, &error); 

    ABMutableMultiValueRef multiPhone =  ABMultiValueCreateMutable(kABMultiStringPropertyType); 
ABMultiValueAddValueAndLabel(multiPhone, people.phone, kABPersonPhoneMainLabel, NULL); 
ABMultiValueAddValueAndLabel(multiPhone, people.other, kABOtherLabel, NULL);    
ABRecordSetValue(newPerson, kABPersonPhoneProperty, multiPhone,nil); 
CFRelease(multiPhone); 
    // ... 
    // Set other properties 
    // ... 
    ABAddressBookAddRecord(iPhoneAddressBook, newPerson, &error); 

ABAddressBookSave(iPhoneAddressBook, &error); 
    CFRelease(newPerson); 
    CFRelease(iPhoneAddressBook); 
if (error != NULL) 
{ 
     CFStringRef errorDesc = CFErrorCopyDescription(error); 
    NSLog(@"Contact not saved: %@", errorDesc); 
     CFRelease(errorDesc);   
} 
+0

pero tengo una pequeña pregunta, ¿qué pasa con el ahorro de un número de teléfono, lo que es la propiedad que tenemos que hacer uso de –

+0

@EshwarChaitanya Aquí está la completa http referencia: //heig.ch/sohi Tienes que buscar 'kABPersonPhoneProperty' –

+0

Sí lo tengo Mr.J_freyre –

Cuestiones relacionadas