ios-get contact information for contacts

Source: Internet
Author: User

Header file
#import <AddressBook/AddressBook.h>#import <AddressBookUI/AddressBookUI.h>
Authorized

About the authorization of the Address Book there is no more to say, I mentioned in the previous article: Contacts Authorization

Access Address Book

Jump to System Address Book

-(void) jumpaddress{    *PEOPLEPICKVC = [[Abpeoplepickernavigationcontroller alloc] init];    = self ;    [Self PRESENTVIEWCONTROLLER:PEOPLEPICKVC animated:yes completion:nil];}

Add Agent

@interface Viewcontroller () <abpeoplepickernavigationcontrollerdelegate, uinavigationcontrollerdelegate>

Proxy method

/// deselect -(void) Peoplepickernavigationcontrollerdidcancel: (Abpeoplepickernavigationcontroller * ) peoplepicker{    }

///after implementing this method, the following proxy methods will not be implemented (this method is to click the name directly in the Address book list to call and dismiss)- (void) Peoplepickernavigationcontroller: (abpeoplepickernavigationcontroller*) Peoplepicker Didselectperson: (abrecordref) person {//get the current contact nameNSString *firstname= (__bridge NSString *) (Abrecordcopyvalue (person, kabpersonfirstnameproperty)); //get current Contact last nameNSString *lastname= (__bridge NSString *) (Abrecordcopyvalue (person, kabpersonlastnameproperty)); //get an array of phone numbers for the current contactNsmutablearray *phonearray =[[Nsmutablearray alloc]init]; Abmultivalueref Phones=Abrecordcopyvalue (person, kabpersonphoneproperty);  for(Nsinteger j=0; J<abmultivaluegetcount (phones); J + +) {NSString*phone = (__bridge NSString *) (Abmultivaluecopyvalueatindex (phones, j)); NSLog (@"phone=%@", phone);    [Phonearray Addobject:phone]; }    //gets the current contact's mailbox note is an arrayNsmutablearray *emailarray =[[Nsmutablearray alloc]init]; Abmultivalueref emails=Abrecordcopyvalue (person, kabpersonemailproperty);  for(Nsinteger j=0; J<abmultivaluegetcount (emails); J + +) {NSString*email = (__bridge NSString *) (Abmultivaluecopyvalueatindex (emails, j)); NSLog (@"email=%@", email);    [Emailarray Addobject:email]; }    //get the current contact middle nameNSString *middlename= (__bridge nsstring*) (Abrecordcopyvalue (person, kabpersonmiddlenameproperty)); //gets the name prefix of the current contactNSString *prefix= (__bridge nsstring*) (Abrecordcopyvalue (person, kabpersonprefixproperty)); //gets the name suffix of the current contactNSString *suffix= (__bridge nsstring*) (Abrecordcopyvalue (person, kabpersonsuffixproperty)); //get the nickname of the current contactNSString *nickname= (__bridge nsstring*) (Abrecordcopyvalue (person, kabpersonnicknameproperty)); //get the name of the current contact PinyinNSString *firstnamephoneic= (__bridge nsstring*) (Abrecordcopyvalue (person, kabpersonfirstnamephoneticproperty)); //gets the current contact's last name PinyinNSString *lastnamephoneic= (__bridge nsstring*) (Abrecordcopyvalue (person, kabpersonlastnamephoneticproperty)); //gets the middle name of the current contact PinyinNSString *middlenamephoneic= (__bridge nsstring*) (Abrecordcopyvalue (person, kabpersonmiddlenamephoneticproperty)); //get the company of the current contactNSString *organization= (__bridge nsstring*) (Abrecordcopyvalue (person, kabpersonorganizationproperty)); //get the current contact's positionNSString *job= (__bridge nsstring*) (Abrecordcopyvalue (person, kabpersonjobtitleproperty)); //get the Department of the current contactNSString *department= (__bridge nsstring*) (Abrecordcopyvalue (person, kabpersondepartmentproperty)); //get the current contact's birthday//nsstring *birthday= (__bridge nsdate*) (Abrecordcopyvalue (person, kabpersonbirthdayproperty)); //get notes for the current contactNSString *notes= (__bridge nsstring*) (Abrecordcopyvalue (person, kabpersonnoteproperty)); //gets the time to create the current contact note is NSDateNSDate *creattime= (__bridge nsdate*) (Abrecordcopyvalue (person, kabpersoncreationdateproperty)); //gets the time that the current contact was last modifiedNSDate *altertime= (__bridge nsdate*) (Abrecordcopyvalue (person, kabpersonmodificationdateproperty)); //get the current contact avatar pictureNSData *userimage= (__bridge nsdata*) (Abpersoncopyimagedata (person)); //get current Contact anniversaryNsmutablearray *datearr =[[Nsmutablearray alloc]init]; Abmultivalueref dates=Abrecordcopyvalue (person, kabpersondateproperty);  for(Nsinteger j=0; J<abmultivaluegetcount (dates); J + +) {        //Get Anniversary DateNSDate *data = (__bridge nsdate*) (Abmultivaluecopyvalueatindex (dates, j)); //Get Anniversary nameNSString *str = (__bridge nsstring*) (Abmultivaluecopylabelatindex (dates, j)); }}

/// after implementing this method, the proxy method above will not be implemented (this method is to enter the Address book details after clicking on the name or phone call and dismiss)-(void) Peoplepickernavigationcontroller: ( abpeoplepickernavigationcontroller*) peoplepicker Didselectperson: (abrecordref) Person property: (Abpropertyid) Property identifier: (abmultivalueidentifier) identifier Ns_available_ios (8_0) {}

Note: The above two select callback agent implementation of one can be

Related reference: http://www.jb51.net/article/95500.htm

Ios-Get contact information for contacts

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.