ABAddressBookRef addressBook = ABAddressBookCreate();

    CFArrayRef results = ABAddressBookCopyArrayOfAllPeople(addressBook);

    for(int i = 0; i < CFArrayGetCount(results); i++)
{
ABRecordRef person = CFArrayGetValueAtIndex(results, i);
//读取firstname
NSString *personName = (NSString*)ABRecordCopyValue(person, kABPersonFirstNameProperty);
if(personName != nil)
textView.text = [textView.text stringByAppendingFormat:@"\n姓名:%@\n",personName];
//读取lastname
NSString *lastname = (NSString*)ABRecordCopyValue(person, kABPersonLastNameProperty);
if(lastname != nil)
textView.text = [textView.text stringByAppendingFormat:@"%@\n",lastname];
//读取middlename
NSString *middlename = (NSString*)ABRecordCopyValue(person, kABPersonMiddleNameProperty);
if(middlename != nil)
textView.text = [textView.text stringByAppendingFormat:@"%@\n",middlename];
//读取prefix前缀
NSString *prefix = (NSString*)ABRecordCopyValue(person, kABPersonPrefixProperty);
if(prefix != nil)
textView.text = [textView.text stringByAppendingFormat:@"%@\n",prefix];
//读取suffix后缀
NSString *suffix = (NSString*)ABRecordCopyValue(person, kABPers*****uffixProperty);
if(suffix != nil)
textView.text = [textView.text stringByAppendingFormat:@"%@\n",suffix];
//读取nickname呢称
NSString *nickname = (NSString*)ABRecordCopyValue(person, kABPersonNicknameProperty);
if(nickname != nil)
textView.text = [textView.text stringByAppendingFormat:@"%@\n",nickname];
//读取firstname拼音音标
NSString *firstnamePhonetic = (NSString*)ABRecordCopyValue(person, kABPersonFirstNamePhoneticProperty);
if(firstnamePhonetic != nil)
textView.text = [textView.text stringByAppendingFormat:@"%@\n",firstnamePhonetic];
//读取lastname拼音音标
NSString *lastnamePhonetic = (NSString*)ABRecordCopyValue(person, kABPersonLastNamePhoneticProperty);
if(lastnamePhonetic != nil)
textView.text = [textView.text stringByAppendingFormat:@"%@\n",lastnamePhonetic];
//读取middlename拼音音标
NSString *middlenamePhonetic = (NSString*)ABRecordCopyValue(person, kABPersonMiddleNamePhoneticProperty);
if(middlenamePhonetic != nil)
textView.text = [textView.text stringByAppendingFormat:@"%@\n",middlenamePhonetic];
//读取organization公司
NSString *organization = (NSString*)ABRecordCopyValue(person, kABPersonOrganizationProperty);
if(organization != nil)
textView.text = [textView.text stringByAppendingFormat:@"%@\n",organization];
//读取jobtitle工作
NSString *jobtitle = (NSString*)ABRecordCopyValue(person, kABPersonJobTitleProperty);
if(jobtitle != nil)
textView.text = [textView.text stringByAppendingFormat:@"%@\n",jobtitle];
//读取department部门
NSString *department = (NSString*)ABRecordCopyValue(person, kABPersonDepartmentProperty);
if(department != nil)
textView.text = [textView.text stringByAppendingFormat:@"%@\n",department];
//读取birthday生日
NSDate *birthday = (NSDate*)ABRecordCopyValue(person, kABPersonBirthdayProperty);
if(birthday != nil)
textView.text = [textView.text stringByAppendingFormat:@"%@\n",birthday];
//读取note备忘录
NSString *note = (NSString*)ABRecordCopyValue(person, kABPersonNoteProperty);
if(note != nil)
textView.text = [textView.text stringByAppendingFormat:@"%@\n",note];
//第一次添加该条记录的时间
NSString *firstknow = (NSString*)ABRecordCopyValue(person, kABPersonCreationDateProperty);
NSLog(@"第一次添加该条记录的时间%@\n",firstknow);
//最后一次修改該条记录的时间
NSString *lastknow = (NSString*)ABRecordCopyValue(person, kABPersonModificationDateProperty);
NSLog(@"最后一次修改該条记录的时间%@\n",lastknow); //获取email多值
ABMultiValueRef email = ABRecordCopyValue(person, kABPersonEmailProperty);
int emailcount = ABMultiValueGetCount(email);
for (int x = 0; x < emailcount; x++)
{
//获取email Label
NSString* emailLabel = (NSString*)ABAddressBookCopyLocalizedLabel(ABMultiValueCopyLabelAtIndex(email, x));
//获取email值
NSString* emailContent = (NSString*)ABMultiValueCopyValueAtIndex(email, x);
textView.text = [textView.text stringByAppendingFormat:@"%@:%@\n",emailLabel,emailContent];
}
//读取地址多值
ABMultiValueRef address = ABRecordCopyValue(person, kABPersonAddressProperty);
int count = ABMultiValueGetCount(address); for(int j = 0; j < count; j++)
{
//获取地址Label
NSString* addressLabel = (NSString*)ABMultiValueCopyLabelAtIndex(address, j);
textView.text = [textView.text stringByAppendingFormat:@"%@\n",addressLabel];
//获取該label下的地址6属性
NSDictionary* personaddress =(NSDictionary*) ABMultiValueCopyValueAtIndex(address, j);
NSString* country = [personaddress valueForKey:(NSString *)kABPersonAddressCountryKey];
if(country != nil)
textView.text = [textView.text stringByAppendingFormat:@"国家:%@\n",country];
NSString* city = [personaddress valueForKey:(NSString *)kABPersonAddressCityKey];
if(city != nil)
textView.text = [textView.text stringByAppendingFormat:@"城市:%@\n",city];
NSString* state = [personaddress valueForKey:(NSString *)kABPersonAddressStateKey];
if(state != nil)
textView.text = [textView.text stringByAppendingFormat:@"省:%@\n",state];
NSString* street = [personaddress valueForKey:(NSString *)kABPersonAddressStreetKey];
if(street != nil)
textView.text = [textView.text stringByAppendingFormat:@"街道:%@\n",street];
NSString* zip = [personaddress valueForKey:(NSString *)kABPersonAddressZIPKey];
if(zip != nil)
textView.text = [textView.text stringByAppendingFormat:@"邮编:%@\n",zip];
NSString* coutntrycode = [personaddress valueForKey:(NSString *)kABPersonAddressCountryCodeKey];
if(coutntrycode != nil)
textView.text = [textView.text stringByAppendingFormat:@"国家编号:%@\n",coutntrycode];
} //获取dates多值
ABMultiValueRef dates = ABRecordCopyValue(person, kABPersonDateProperty);
int datescount = ABMultiValueGetCount(dates);
for (int y = 0; y < datescount; y++)
{
//获取dates Label
NSString* datesLabel = (NSString*)ABAddressBookCopyLocalizedLabel(ABMultiValueCopyLabelAtIndex(dates, y));
//获取dates值
NSString* datesContent = (NSString*)ABMultiValueCopyValueAtIndex(dates, y);
textView.text = [textView.text stringByAppendingFormat:@"%@:%@\n",datesLabel,datesContent];
}
//获取kind值
CFNumberRef recordType = ABRecordCopyValue(person, kABPersonKindProperty);
if (recordType == kABPersonKindOrganization) {
// it's a company
NSLog(@"it's a company\n");
} else {
// it's a person, resource, or room
NSLog(@"it's a person, resource, or room\n");
} //获取IM多值
ABMultiValueRef instantMessage = ABRecordCopyValue(person, kABPersonInstantMessageProperty);
for (int l = 1; l < ABMultiValueGetCount(instantMessage); l++)
{
//获取IM Label
NSString* instantMessageLabel = (NSString*)ABMultiValueCopyLabelAtIndex(instantMessage, l);
textView.text = [textView.text stringByAppendingFormat:@"%@\n",instantMessageLabel];
//获取該label下的2属性
NSDictionary* instantMessageContent =(NSDictionary*) ABMultiValueCopyValueAtIndex(instantMessage, l);
NSString* username = [instantMessageContent valueForKey:(NSString *)kABPersonInstantMessageUsernameKey];
if(username != nil)
textView.text = [textView.text stringByAppendingFormat:@"username:%@\n",username]; NSString* service = [instantMessageContent valueForKey:(NSString *)kABPersonInstantMessageServiceKey];
if(service != nil)
textView.text = [textView.text stringByAppendingFormat:@"service:%@\n",service];
} //读取电话多值
ABMultiValueRef phone = ABRecordCopyValue(person, kABPersonPhoneProperty);
for (int k = 0; k<ABMultiValueGetCount(phone); k++)
{
//获取电话Label
NSString * personPhoneLabel = (NSString*)ABAddressBookCopyLocalizedLabel(ABMultiValueCopyLabelAtIndex(phone, k));
//获取該Label下的电话值
NSString * personPhone = (NSString*)ABMultiValueCopyValueAtIndex(phone, k); textView.text = [textView.text stringByAppendingFormat:@"%@:%@\n",personPhoneLabel,personPhone];
} //获取URL多值
ABMultiValueRef url = ABRecordCopyValue(person, kABPersonURLProperty);
for (int m = 0; m < ABMultiValueGetCount(url); m++)
{
//获取电话Label
NSString * urlLabel = (NSString*)ABAddressBookCopyLocalizedLabel(ABMultiValueCopyLabelAtIndex(url, m));
//获取該Label下的电话值
NSString * urlContent = (NSString*)ABMultiValueCopyValueAtIndex(url,m); textView.text = [textView.text stringByAppendingFormat:@"%@:%@\n",urlLabel,urlContent];
} //读取照片
NSData *image = (NSData*)ABPersonCopyImageData(person); UIImageView *myImage = [[UIImageView alloc] initWithFrame:CGRectMake(200, 0, 50, 50)];
[myImage setImage:[UIImage imageWithData:image]];
myImage.opaque = YES;
[textView addSubview:myImage]; } CFRelease(results);
CFRelease(addressBook);

ios 开发,通讯录信息调用常用方法,这个比较全,不用再整理了的更多相关文章

  1. ios读取通讯录信息

    ios读取通讯录信息 (2012-05-22 14:07:11) 标签: ios读取通讯录 it   iphone如许app读取通讯录信息,读取通讯录信息时需要加载AddressBookUI 和Add ...

  2. ios开发中如何调用苹果自带地图导航

    前段时间一直在赶项目,在外包公司工作就是命苦,天天加班不说,工作都是和工期合同挂钩的,稍微逾期就有可能被扣奖金,不谈这些伤脑筋的事情了,让我们说说iOS开发中如何调用苹果手机自带的地图. 学习如逆水行 ...

  3. ios开发 通讯录

    一.通信录开发 通信录开发主要是获取用户手机中的联系人 通过获取用户的通信录,可以在应用中添加好友等 二.如何访问用户的通讯录 在iOS9之前,有2个框架可以访问用户的通讯录 目前需要适配iOS8,所 ...

  4. iOS开发——高级技术&调用地图功能的实现

    调用地图功能的实现 一:苹果自带地图 学习如逆水行舟,不进则退.古人告诉我们要不断的反思和总结,日思则日精,月思则月精,年思则年精.只有不断的尝试和总结,才能让我们的工作和生活更加 轻松愉快和美好.连 ...

  5. MacOS和iOS开发中异步调用与多线程的区别

    很多童鞋可能对Apple开发中的异步调用和多线程的区别不是太清楚,这里本猫将用一些简单的示例来展示一下它们到底直观上有神马不同. 首先异步调用可以在同一个线程中,也可以在多个不同的线程中.每个线程都有 ...

  6. ios开发总结:Utils常用方法等收集,添加扩展类,工具类方法,拥有很多方便快捷功能(不断更新中。。。)

    BOBUtils 工具大全 本人github开源和收集功能地址:https://github.com/niexiaobo [对ios新手或者工作一年以内开发人员很有用处] 常用方法等收集.添加扩展类. ...

  7. iOS开发——设备信息小结(未完待续...)

    1.获取设备的信息  UIDevice *device = [[UIDevice alloc] init]; NSString *name = device.name;       //获取设备所有者 ...

  8. iOS开发-通讯录有界面

    // //  ViewController.m //  06-通讯录(有界面) // #import "ViewController.h" #import <AddressB ...

  9. ios开发,app调用资源文件到C++的方法

    为了读取资源文件到cpp.供opencv处理,采取的方式是把之前的cpp文件的后缀改成:.mm 然后会出现各种报错,原因是因为命名冲突,前面加上cv::就行. const char* imagePat ...

随机推荐

  1. PHP-mysqllib和mysqlnd

    1.什么是mysqlnd驱动? PHP手册上的描述:MySQL Native Driver is a replacement for the MySQL Client Library (libmysq ...

  2. LNMP-查看安装编译时参数

    查看mysql编译参数: cat /usr/local/mysql/bin/mysqlbug | grep CONFIGURE_LINE 查看apache编译参数: cat $apachehome$/ ...

  3. PCA和Softmax分类比较—Mnist与人脸数据集

    PCA人脸识别中三种方法得到的正确率可达到100% 作为对比,单独使用Softmax回归对人脸40*10*92*112的数据分类正确率为97%. 用PCA对MNIST手写数字10*500*28*28识 ...

  4. EDIUS和会声会影的区别

    最近经常听到大家讨论会声会影和EDIUS哪个好,有人说会声会影就相当于傻瓜相机,EDIUS相当于手动的相机:也有人说拍着玩的,简单玩玩的用会声会影,做出来画面很绚丽:剪辑片子,特效合成专业的就用EDI ...

  5. 012. asp.net生成验证码图片(汉字示例/字母+数字)

    protected void Page_Load(object sender, EventArgs e) { //生成验证码图片的基本步骤 string checkCode = "新年快乐& ...

  6. qemu-kvm命令

    三种方式创建虚拟机 1.qemu-kvm来创建虚拟机 通过阅读man qemu-kvm手册而清楚的. 于20160430阅读 [root@kvm1 ~]# /usr/libexec/qemu-kvm ...

  7. python3倒叙字符串

    google测试工程师的一道题: 设计一个函数,使用任意语言,完成以下功能: 一个句子,将句子中的单词全部倒排过来,但单词的字母顺序不变.比如,This is a real world,输出结果为 w ...

  8. ExtJs学习笔记之ComboBox组件

    ComboBox组件 (1)ComboBox控件支持自动完成.远程加载.和许多其他特性. (2)ComboBox就像是传统的HTML文本 <input> 域和 <select> ...

  9. jQuery Mobile_公司简介

    <!doctype html> <html> <head> <meta charset="utf-8"> <meta name ...

  10. ASP.NET MVC中的错误-友好的处理方法

    转自:http://blog.csdn.net/lizhao1226/article/details/6367400 “/”应用程序中的服务器错误. 无法找到资源. 说明: HTTP 404.您正在查 ...