ios 获得通讯录中联系人的所有属性 亲测,可行 兼容io6 和 ios 7
2019独角兽企业重金招聘Python工程师标准>>>
//获取通讯录中的所有属性,并存储在 textView 中,已检验,切实可行。兼容io6 和 ios 7 ,而且ios7还没有权限确认提示。
-()getAddressBook
{ABAddressBookRef addressBook = ABAddressBookCreate();CFArrayRef results = ABAddressBookCopyArrayOfAllPeople(addressBook); ( i = ; i < CFArrayGetCount(results); i++){ABRecordRef person = CFArrayGetValueAtIndex(results, i); NSString *personName = (NSString*)ABRecordCopyValue(person, kABPersonFirstNameProperty); (personName != nil)textView.text = [textView.text stringByAppendingFormat:,personName]; NSString *lastname = (NSString*)ABRecordCopyValue(person, kABPersonLastNameProperty); (lastname != nil)textView.text = [textView.text stringByAppendingFormat:,lastname]; NSString *middlename = (NSString*)ABRecordCopyValue(person, kABPersonMiddleNameProperty); (middlename != nil)textView.text = [textView.text stringByAppendingFormat:,middlename]; NSString *prefix = (NSString*)ABRecordCopyValue(person, kABPersonPrefixProperty); (prefix != nil)textView.text = [textView.text stringByAppendingFormat:,prefix]; NSString *suffix = (NSString*)ABRecordCopyValue(person, kABPersonSuffixProperty); (suffix != nil)textView.text = [textView.text stringByAppendingFormat:,suffix]; NSString *nickname = (NSString*)ABRecordCopyValue(person, kABPersonNicknameProperty); (nickname != nil)textView.text = [textView.text stringByAppendingFormat:,nickname]; NSString *firstnamePhonetic = (NSString*)ABRecordCopyValue(person, kABPersonFirstNamePhoneticProperty); (firstnamePhonetic != nil)textView.text = [textView.text stringByAppendingFormat:,firstnamePhonetic]; NSString *lastnamePhonetic = (NSString*)ABRecordCopyValue(person, kABPersonLastNamePhoneticProperty); (lastnamePhonetic != nil)textView.text = [textView.text stringByAppendingFormat:,lastnamePhonetic]; NSString *middlenamePhonetic = (NSString*)ABRecordCopyValue(person, kABPersonMiddleNamePhoneticProperty); (middlenamePhonetic != nil)textView.text = [textView.text stringByAppendingFormat:,middlenamePhonetic]; NSString *organization = (NSString*)ABRecordCopyValue(person, kABPersonOrganizationProperty); (organization != nil)textView.text = [textView.text stringByAppendingFormat:,organization]; NSString *jobtitle = (NSString*)ABRecordCopyValue(person, kABPersonJobTitleProperty); (jobtitle != nil)textView.text = [textView.text stringByAppendingFormat:,jobtitle]; NSString *department = (NSString*)ABRecordCopyValue(person, kABPersonDepartmentProperty); (department != nil)textView.text = [textView.text stringByAppendingFormat:,department]; NSDate *birthday = (NSDate*)ABRecordCopyValue(person, kABPersonBirthdayProperty); (birthday != nil)textView.text = [textView.text stringByAppendingFormat:,birthday]; NSString *note = (NSString*)ABRecordCopyValue(person, kABPersonNoteProperty); (note != nil)textView.text = [textView.text stringByAppendingFormat:,note]; NSString *firstknow = (NSString*)ABRecordCopyValue(person, kABPersonCreationDateProperty);NSLog(,firstknow); NSString *lastknow = (NSString*)ABRecordCopyValue(person, kABPersonModificationDateProperty);NSLog(,lastknow); ABMultiValueRef email = ABRecordCopyValue(person, kABPersonEmailProperty); emailcount = ABMultiValueGetCount(email); ( x = ; x < emailcount; x++){ NSString* emailLabel = (NSString*)ABAddressBookCopyLocalizedLabel(ABMultiValueCopyLabelAtIndex(email, x)); NSString* emailContent = (NSString*)ABMultiValueCopyValueAtIndex(email, x);textView.text = [textView.text stringByAppendingFormat:,emailLabel,emailContent];} ABMultiValueRef address = ABRecordCopyValue(person, kABPersonAddressProperty); count = ABMultiValueGetCount(address); ( j = ; j < count; j++){ NSString* addressLabel = (NSString*)ABMultiValueCopyLabelAtIndex(address, j);textView.text = [textView.text stringByAppendingFormat:,addressLabel]; NSDictionary* personaddress =(NSDictionary*) ABMultiValueCopyValueAtIndex(address, j);NSString* country = [personaddress valueForKey:(NSString *)kABPersonAddressCountryKey]; (country != nil)textView.text = [textView.text stringByAppendingFormat:,country];NSString* city = [personaddress valueForKey:(NSString *)kABPersonAddressCityKey]; (city != nil)textView.text = [textView.text stringByAppendingFormat:,city];NSString* state = [personaddress valueForKey:(NSString *)kABPersonAddressStateKey]; (state != nil)textView.text = [textView.text stringByAppendingFormat:,state];NSString* street = [personaddress valueForKey:(NSString *)kABPersonAddressStreetKey]; (street != nil)textView.text = [textView.text stringByAppendingFormat:,street];NSString* zip = [personaddress valueForKey:(NSString *)kABPersonAddressZIPKey]; (zip != nil)textView.text = [textView.text stringByAppendingFormat:,zip];NSString* coutntrycode = [personaddress valueForKey:(NSString *)kABPersonAddressCountryCodeKey]; (coutntrycode != nil)textView.text = [textView.text stringByAppendingFormat:,coutntrycode];} ABMultiValueRef dates = ABRecordCopyValue(person, kABPersonDateProperty); datescount = ABMultiValueGetCount(dates); ( y = ; y < datescount; y++){ NSString* datesLabel = (NSString*)ABAddressBookCopyLocalizedLabel(ABMultiValueCopyLabelAtIndex(dates, y)); NSString* datesContent = (NSString*)ABMultiValueCopyValueAtIndex(dates, y);textView.text = [textView.text stringByAppendingFormat:,datesLabel,datesContent];} CFNumberRef recordType = ABRecordCopyValue(person, kABPersonKindProperty); (recordType == kABPersonKindOrganization) { NSLog();} { NSLog();} ABMultiValueRef instantMessage = ABRecordCopyValue(person, kABPersonInstantMessageProperty); ( l = ; l < ABMultiValueGetCount(instantMessage); l++){ NSString* instantMessageLabel = (NSString*)ABMultiValueCopyLabelAtIndex(instantMessage, l);textView.text = [textView.text stringByAppendingFormat:,instantMessageLabel]; NSDictionary* instantMessageContent =(NSDictionary*) ABMultiValueCopyValueAtIndex(instantMessage, l);NSString* username = [instantMessageContent valueForKey:(NSString *)kABPersonInstantMessageUsernameKey]; (username != nil)textView.text = [textView.text stringByAppendingFormat:,username];NSString* service = [instantMessageContent valueForKey:(NSString *)kABPersonInstantMessageServiceKey]; (service != nil)textView.text = [textView.text stringByAppendingFormat:,service];} ABMultiValueRef phone = ABRecordCopyValue(person, kABPersonPhoneProperty); ( k = ; k<ABMultiValueGetCount(phone); k++){ NSString * personPhoneLabel = (NSString*)ABAddressBookCopyLocalizedLabel(ABMultiValueCopyLabelAtIndex(phone, k)); NSString * personPhone = (NSString*)ABMultiValueCopyValueAtIndex(phone, k);textView.text = [textView.text stringByAppendingFormat:,personPhoneLabel,personPhone];} ABMultiValueRef url = ABRecordCopyValue(person, kABPersonURLProperty); ( m = ; m < ABMultiValueGetCount(url); m++){ NSString * urlLabel = (NSString*)ABAddressBookCopyLocalizedLabel(ABMultiValueCopyLabelAtIndex(url, m)); NSString * urlContent = (NSString*)ABMultiValueCopyValueAtIndex(url,m);textView.text = [textView.text stringByAppendingFormat:,urlLabel,urlContent];} NSData *image = (NSData*)ABPersonCopyImageData(person);UIImageView *myImage = [[UIImageView alloc] initWithFrame:CGRectMake(, , , )];[myImage setImage:[UIImage imageWithData:image]];myImage.opaque = YES;[textView addSubview:myImage];}CFRelease(results);CFRelease(addressBook);
}
转载于:https://my.oschina.net/u/2559341/blog/596852
ios 获得通讯录中联系人的所有属性 亲测,可行 兼容io6 和 ios 7相关推荐
- ios获得通讯录中联系人的所有属性
ABAddressBookRef addressBook = ABAddressBookCreate();CFArrayRef results = ABAddressBookCopyArrayOfAl ...
- 在企业级案例中进阶excel资源-亲测十分有用
在企业级案例中进阶excel资源-亲测十分有用 对于已入门Excel,但还不能用Excel熟练分析业务数据.高效使用的同学来说,是不错的进阶课程 这是一个以企业级案例为核心的课程.老师会在课程中演示案 ...
- 数据库安装时需要更新以前的Visual Studio 2010实例状态失败-----亲测可行
数据库安装时"需要更新以前的Visual Studio 2010实例"状态失败 ...
- Ubuntu18.04安装ROS最后的rosdep update不成功解决方案(亲测可行)
Ubuntu18.04安装ROS最后的rosdep update不成功解决方案(亲测可行) 问题描述 很多人在安装ROS时会卡在最后一步rosdep update上面,虽然这一步不成功并不影响小海龟的 ...
- [亲测可行]Ubuntu16.04+opencv3.4+opencv_contrib+cuda9.0安装
这篇博客主要总结下在Ubuntu下安装opencv以及扩展库所遇到的问题,以及解决的方案. Opencv版本:3.4.7+CUDA9.0+1060 一.下载Opencv+contrib 在Opencv ...
- 如何下载一篇文献的所有被引文献(傻瓜式操作,亲测可行,方便快捷,需要教育账号)
最近学习一篇文献时,需要查看所有引用过这篇文献的文章,并且下载出来.当然,如果引用的文献较少的话,可以通过网页直接搜索下载下来.但是如果超过10篇以上,我就会感觉比较繁琐.那么,有没有什么方法可以一键 ...
- win10双磁盘安装ubuntu16.04双系统 GTX1660Ti+UEFI+GPT 亲测可行
有独显的笔记本在安装ubuntu系统的时候都会比较折腾,网上教程多且繁杂,每次安装都会遇到不同的问题,很多教程上会经常遇到卡在ubuntu的logo界面不动的情况,我就没有遇到,所以这件事情还是按照自 ...
- Windows下命令行及Java+Tesseract-OCR对图像进行(字母+数字+中文)识别,亲测可行
Windows下Java+Tesseract-OCR对图像进行字符识别,亲测可行 1. 下载tesseract-ocr.中文语言包并安装 2. 命令行对图片进行识别及效果图 3. Java调用Tess ...
- vegas pro 15解决导入的视频和音频有噪声问题,亲测可行
vegas pro 15解决导入的视频和音频有噪声问题,亲测可行 参考文章: (1)vegas pro 15解决导入的视频和音频有噪声问题,亲测可行 (2)https://www.cnblogs.co ...
最新文章
- 全新的深度模型在推荐系统中的应用
- HDLBits 系列(29)PS/2 mouse protocol(PS/2 packet parser and datapath)
- C++构造函数和析构函数调用虚函数时都不会使用动态联编
- Java并发编程实战_一线大厂架构师整理:java并发编程实践教程
- python新闻爬虫教程_python简易爬虫教程--(一)批量获取搜狐新闻
- 补丁 检测系统_大云制造 | BCLinux For ARM64 V7.6操作系统正式发布
- C++(STL):10---vector空间分配
- 111 《深入理解Java虚拟机》读书笔记
- 《编码-隐匿在计算机软硬背后的语言》第七章我们的十个数字
- python数据结构教程_python入门基础教程随笔1-python数据结构-列表
- Android EditText 不得不说的InputFilter、TextWatcher、ActionMode.Callback、OnEditorActionListener
- 易语言内存不能为read错误解决方案和提高程序运行速度【转载】
- Knowledge Tracing 资源帖2
- java实现银行卡卡号 Luhm 校验算法
- 数学建模学习(98):CHIO优化算法
- 华为云服务部署Rstudio Server
- 小程序项目从Hbuilder转移到vscode步骤
- 华为云服务之计算服务
- sql语句练习题或面试题
- 三星“掌门人”李在镕身在看守所 但仍“遥控”三星
热门文章
- 电脑硬件配置——组装查询软件
- mysql忘记密麻麻_mysql忘记密码怎么办
- sklearn 相似度矩阵_精简易懂,30 分钟学会 SVD 矩阵分解,很强!
- python中的方法和函数的区别_python中函数与方法的区别?
- plsql oracle服务端,PLSQL Developer + Oracle客户端简易安装方法
- 计算机网络日,《计算机网络原理》教学日历[汇编].pdf
- Docker容器之macvlan网络
- Java高并发编程:取消和关闭
- python怎么显示分数_python分数怎么表示什么
- hdfs通过接口退出安全模式_Hadoop之HDFS简介