ios - How to get Mobile Number from vCard String Objective C -
i working on action extension objective c. have created extension share recent contact in extension. in getting v card string. how can mobile number v card string. appreciated.
using contactswithdata:error:
class method of cncontactvcardserialization
, can retrieve info vcard. it's contacts.framework
, available since ios9. earlier version, can use addressbook.framework
. can read info here.
nserror *errorvcf; nsarray *allcontacts = [cncontactvcardserialization contactswithdata:[contactstr datausingencoding:nsutf8stringencoding] error:&errorvcf]; if (!errorvcf) { nsmutablestring *results = [[nsmutablestring alloc] init]; //nslog(@"allcontacts: %@", allcontacts); (cncontact *acontact in allcontacts) { nsarray *phonesnumbers = [acontact phonenumbers]; (cnlabeledvalue *avalue in phonesnumbers) { cnphonenumber *phonenumber = [avalue value]; [results appendformat:@"%@ %@\n", [avalue label], [phonenumber stringvalue]]; } } nslog(@"final: %@", results); }
Comments
Post a Comment