@ IOS calls the library file used to operate the address book
AddressBook. framework
AddressBookUI. framework
# Import "HMTMainViewController. h "# import @ interface HMTMainViewController () @ property (nonatomic, strong) ABPeoplePickerNavigationController * personPickVC; @ property (nonatomic, strong) UIWebView * phoneCallWebView; @ end @ implementation HMTMainViewController-(id) initWithNibName :( NSString *) bundle :( NSBundle *) handle {self = [super initWithNibName: nibNameOrNil bundle: callback]; if (self) {// initim initialization} return self;}-(void) viewDidLoad {[super viewDidLoad]; // Do any additional setup after loading the view. self. navigationItem. title = @ "system address book"; // self. navigationItem. leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle: @ "delete" style: Custom target: self action: @ selector (operator)]; UIButton * button = [UIButton buttonWithType: identifier]; button. frame = CGRectMake (100, 70,120, 40); [button setTitle: @ "select contact" forState: UIControlStateNormal]; [button addTarget: self action: @ selector (didClickSelectAction) forControlEvents: UIControlEventTouchUpInside]; [self. view addSubview: button];}-(void) didClickSelectAction {// select the contact self of the phone book. personPickVC = [[abw.javasickernavigationcontroller alloc] init]; _ personPickVC. required parameter ickerdelegate = self; _ personPickVC. displayedProperties = @ [NSNumber numberWithInt: kABPersonPhoneProperty]; [self deletePerson]; [self presentViewController: _ personPickVC animated: YES completion: NULL]; // [self. navigationController pushViewController: [_ personPickVC. viewControllers objectAtIndex: 0] animated: YES]; // [self getAllPerson];} // enter the contact selection page-(BOOL) register an ickernavigationcontroller :( ABPeoplePickerNavigationController *) specify an existing icker identifier :( ABRecordRef) person {// After the contact is selected, the system exits and returns the expected attribute [commandid icker dismissViewControllerAnimated: YES completion: ^ {NSString * firstName = (_ bridge NSString *) ABRecordCopyValue (person, response); NSLog (@ "person = % @", firstName); ABMultiValueRef phones = ABRecordCopyValue (person, kABPersonPhoneProperty); for (int I = 0; I <ABMultiValueGetCount (phones ); I ++) {NSString * phone = (_ bridge NSString *) (ABMultiValueCopyValueAtIndex (phones, I); NSLog (@ "telephone = % @", phone) ;}}]; return YES;}-(void) Authorization :( ABPeoplePickerNavigationController *) specify parameter icker {[specify parameter icker dismissViewControllerAnimated: YES completion :^{}];}-(BOOL) extends extends ickernavigationcontroller :( ABPeoplePickerNavigationController *) extends icker identifier :( ABRecordRef) person property :( ABPropertyID) property identifier :( ABMultiValueIdentifier) identifier {return YES;} // displays all contacts-(void) getAllPerson {CFArrayRef allPerson = ABAddressBookCopyArrayOfAllPeople (self. personPickVC. addressBook); for (id person in (_ bridge NSArray *) allPerson) {NSString * firstName = (_ bridge NSString *) ABRecordCopyValue (_ bridge ABRecordRef) person, kABPersonFirstNameProperty); NSLog (@ "firstName = % @", firstName); // because a user may have multiple calls, so we need to cyclically retrieve ABMultiValueRef phones = ABRecordCopyValue (_ bridge ABRecordRef) person, kABPersonPhoneProperty); for (int I = 0; I <ABMultiValueGetCount (phones); I ++) {NSString * phone = (_ bridge NSString *) (ABMultiValueCopyValueAtIndex (phones, I); NSLog (@ "telephone = % @", phone );}}} // Add a contact-(void) addPerson {ABAddressBookRef addressBook = self. personPickVC. addressBook; ABRecordRef person = ABPersonCreate (); ABRecordSetValue (person, kABPersonFirstNameProperty, @ "Hu", nil); ABRecordSetValue (person, kABPersonLastNameProperty, @ "mingtao", nil ); ABMutableMultiValueRef mulRef = ABMultiValueCreateMutable (kABStringPropertyType); for (int I = 0; I <1; I ++) {ABMultiValueIdentifier mutableIdentifier; then (mulRef, @ "18690231234", nil, & mutableIdentifier);} ABRecordSetValue (person, kABPersonPhoneProperty, mulRef, nil); ABAddressBookAddRecord (addressBook, person, nil); ABAddressBookSave (addressBook, nil );} // Delete the contact-(void) deletePerson {CFArrayRef allPerson = ABAddressBookCopyArrayOfAllPeople (self. personPickVC. addressBook); for (id person in (_ bridge NSArray *) allPerson) {NSString * firstName = (_ bridge NSString *) ABRecordCopyValue (_ bridge ABRecordRef) person, kABPersonFirstNameProperty); if ([firstName isEqualToString: @ "Hu"]) {ABAddressBookRemoveRecord (self. personPickVC. addressBook, (_ bridge ABRecordRef) person, nil) ;}} ABAddressBookSave (self. personPickVC. addressBook, nil);} // call-(void) dialPhoneNumber :( NSString *) phoneNumber {// 1. UIWebView load call NSURL * phoneURL = [NSURL URLWithString: [NSString stringWithFormat: @ "tel: % @", phoneNumber]; self. phoneCallWebView = [[UIWebView alloc] initWithFrame: CGRectZero]; [self. phoneCallWebView loadRequest: [NSURLRequest requestWithURL: phoneURL]; // 2. private method [[UIApplication sharedApplication] openURL: [NSURL URLWithString: @ "telprompt: // 10086"];}