开发者

How can i add new records in ABPeoplePickerView?

开发者 https://www.devze.com 2023-02-17 06:40 出处:网络
i want to add new records in ABPeoplePickerView and want to retrieve that added record so please any body h开发者_开发百科ave idea about it. CFErrorRef error = NULL;

i want to add new records in ABPeoplePickerView and want to retrieve that added record so please any body h开发者_开发百科ave idea about it.


CFErrorRef error = NULL;

ABAddressBookRef iPhoneAddressBook = ABAddressBookCreate();
ABRecordRef newPerson = ABPersonCreate();
ABMutableMultiValueRef phoneNumberMultiValue =  ABMultiValueCreateMutable(kABPersonPhoneProperty);  
ABMultiValueAddValueAndLabel(phoneNumberMultiValue, StrPhno,  kABHomeLabel, NULL);
ABRecordSetValue(newPerson, kABPersonFirstNameProperty, StrAdress, &error);
ABRecordSetValue(newPerson, kABPersonPhoneProperty, phoneNumberMultiValue, nil); 
ABAddressBookAddRecord(iPhoneAddressBook, newPerson, &error);
ABAddressBookSave(iPhoneAddressBook, &error);

if (error != NULL)
{

    NSLog(@"Danger Will Robinson! Danger!");

}





ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
picker.peoplePickerDelegate = self;
// Display only a person's phone, email, and birthdate
NSArray *displayedItems = [NSArray arrayWithObjects:[NSNumber numberWithInt:kABPersonPhoneProperty], 
                           [NSNumber numberWithInt:kABPersonEmailProperty],
                           [NSNumber numberWithInt:kABPersonBirthdayProperty], nil];


picker.displayedProperties = displayedItems;
// Show the picker 
[self presentModalViewController:picker animated:YES];
[picker release];   
0

精彩评论

暂无评论...
验证码 换一张
取 消