- 浏览: 30707 次
- 性别:
- 来自: 北京
最新评论
获得通讯录中联系人的所有属性 ,看代码:
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, kABPersonSuffixProperty);
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);
原帖地址:http://www.cocoachina.com/bbs/read.php?tid=62527&fpage=2
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, kABPersonSuffixProperty);
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);
原帖地址:http://www.cocoachina.com/bbs/read.php?tid=62527&fpage=2
发表评论
-
AddressBook iOS读取通讯录信息
2013-04-15 15:26 1649iphone如许app读取通讯录信息,读取通讯录信息时需要加载 ... -
MFMessageComposeViewController发送短信
2013-04-11 13:33 1278MFMessageComposeViewController ... -
RESTful HTTP的实践
2013-04-11 12:20 1018本文对RESTful HTTP的基础原理做了一个概览,探讨了开 ... -
IOS使用第三方工具(RegexKitLite)实现正则表达式
2013-04-10 18:19 1883在IOS应用中,经常要输入数据,然输入数据,就要 ... -
iPhone:动态获取UILabel的高度和宽度
2013-04-09 18:10 809在使用UILabel存放字符串时,经常需要获取label的长宽 ... -
iOS 绘制直线、矩形、文字的方式
2013-04-08 10:35 4314首先,获取上下文 CGContextRef context = ... -
iOS 开发小技巧(二)
2013-04-08 09:36 7111、获取全局的Delegate对象,这样我们可以调用这个对象里 ... -
iOS 开发小技巧(一)
2013-04-08 09:27 6811.取字符串中的某段字符串 [plain] view pla ... -
IOS导航栏的创建方法
2013-04-07 15:45 1015基本思路是: 1.创建一个导航栏(UINavigationB ... -
iOS 绘制UIImage的方式
2013-04-07 13:03 2410一:在绘制到context前通过矩阵垂直翻转坐标系 // ui ... -
理解可变参数va_list、va_start、va_arg、va_end原理及使用方法
2013-04-07 12:59 1750在VC++6.0的include有一个stdarg.h头文件, ... -
iOS 开发小技巧(三)
2013-04-06 09:21 6651.判断邮箱格式是否正确的代码 //利用正则表达式验证 -(B ...
相关推荐
这个框架的核心类包括`ABAddressBookRef`,它是整个通讯录的容器,`ABRecordRef`代表一个具体的联系人或群组,而`ABPropertyID`定义了联系人的各个属性,如姓名、电话号码和电子邮件地址。 在开始使用AddressBook...
在iOS平台上,获取通讯录是开发过程中常见的需求,主要用于实现如联系人同步、备份或特定功能的个性化。本文将详细讲解如何使用Objective-C或Swift语言来获取iOS设备上的通讯录,并将单个联系人信息存储到数组中。 ...
可以指定需要获取的联系人属性,如姓名、电话号码等。 5. 处理结果:这些方法会返回一个`Operation`对象,需要在完成处理时进行操作。通常会在`completionHandler`中处理结果。 第二种方式是使用`AddressBook ...
9. **联系人属性**: 除了基本的姓名和电话,AddressBook还支持许多其他属性,如生日、地址、公司、职位等。每个属性都有对应的常量,如`kABPersonAddressProperty`用于地址,`kABPersonNoteProperty`用于备注。 ...
注意,`kABPersonPhoneProperty`是多值属性,意味着一个联系人可能有多个电话号码,因此需要使用`ABMultiValueCopyValueAtIndex`来获取每个电话号码。 在实际开发中,为了适应iOS9及以上版本,你需要使用`Contacts`...
在iOS系统中,通讯录是用户存储联系人信息的重要组成部分,它允许用户管理他们的联系人、电话号码、电子邮件地址等。iOS提供了强大的API,即Contacts框架(在iOS 9及更高版本中)和旧版的AddressBook框架(适用于iOS...
在iOS平台上,获取本地通讯录联系人以及进行汉字首字母排序是常见的功能需求,尤其对于开发涉及用户通讯录的应用来说。下面将详细讲解这个过程,包括如何获取通讯录权限、读取联系人信息以及实现汉字首字母排序。 ...
总之,iOS中的通讯录访问涉及到用户授权、获取联系人列表、处理联系人属性等步骤。通过这个DEMO,你可以学习到如何读取和显示用户的姓名和手机号,同时也可以扩展到获取其他字段,如邮箱、地址等。在实际应用中,还...
总之,iOS获取通讯录涉及到AddressBook框架、权限管理以及对联系人属性的访问。通过这些技术,开发者可以为用户提供如查看、管理通讯录等服务,但必须始终尊重并保护用户的隐私。在实际开发中,应遵守Apple的App ...
例如,创建一个新的联系人并设置一些属性: ```objective-c // 创建ABMutablePerson对象 ABMutablePersonRef newPerson = ABPersonCreate(); // 设置联系人的名字 CFStringRef firstName = CFSTR("John"); ...
1. `SLAddressBook.h`: 这是头文件,定义了类的接口和公共方法,如初始化通讯录存储、获取所有联系人、根据关键词搜索联系人等。 2. `SLAddressBook.m`: 这是实现文件,包含了类的方法实现,如与系统通讯录框架交互...
这个"ios-AddressBookTest.zip"项目显然关注了如何在iOS8及更高版本中处理联系人数据,尤其是如何将AddressBook对象转换为Objective-C对象,并且在iOS9中使用新的CNContact框架来读取和写入联系人属性。下面我们将...
本章节主要聚焦于如何在iOS 5应用中操作通讯录(Address Book),包括获取通讯录引用、读取所有联系人信息等关键操作。这些知识点对于开发需要访问用户联系人的应用程序尤为重要,如社交软件、即时通讯工具或任何...
在iOS开发中,获取用户设备上的通讯录信息是一项常见的需求,比如为了推荐好友或同步联系人数据。本文将详细介绍四种不同的方法来实现这一功能,针对不同的iOS版本和使用场景。 ### 方案一:AddressBookUI....
在iOS开发中,获取iPhone联系人(Contacts)是常见的需求,比如创建社交应用或者需要同步用户通讯录信息的场景。本示例项目“iPhone Contact Demo”提供了一个基础的实现方式,帮助开发者理解如何使用AddressBook...
4. **处理联系人属性** 上述代码中,我们仅获取了联系人的名字(ABPersonCompositeNameFormatFirstNameFirst),但实际应用中可能还需要获取其他属性,如电话号码(kABPersonPhoneProperty)、电子邮件...
接下来,获取AddressBook中所有的联系人记录: ```objc CFArrayRef people = ABAddressBookCopyArrayOfAllPeople(addressBook); ``` `people`是一个`CFArrayRef`类型的数组,包含了所有联系人的记录。你可以遍历这...