首页 > 代码库 > ios获取联系信息
ios获取联系信息
//读取所有联系人
-(void)ReadAllPeoples
{
//取得本地通信录名柄
ABAddressBookRef tmpAddressBook = ABAddressBookCreate();
//取得本地所有联系人记录
NSArray* tmpPeoples = (NSArray*)ABAddressBookCopyArrayOfAllPeople(tmpAddressBook);
for(id tmpPerson in tmpPeoples)
{
//获取的联系人单一属性:First name
NSString* tmpFirstName = (NSString*)ABRecordCopyValue(tmpPerson, kABPersonFirstNameProperty);
[tmpFirstName release];
//获取的联系人单一属性:Last name
NSString* tmpLastName = (NSString*)ABRecordCopyValue(tmpPerson, kABPersonLastNameProperty);
[tmpLastName release];
//获取的联系人单一属性:Nickname
NSString* tmpNickname = (NSString*)ABRecordCopyValue(tmpPerson, kABPersonNicknameProperty);
[tmpNickname release];
//获取的联系人单一属性:Company name
NSString* tmpCompanyname = (NSString*)ABRecordCopyValue(tmpPerson, kABPersonOrganizationProperty);
[tmpCompanyname release];
//获取的联系人单一属性:Job Title
NSString* tmpJobTitle= (NSString*)ABRecordCopyValue(tmpPerson, kABPersonJobTitleProperty);
[tmpJobTitle release];
//获取的联系人单一属性:Department name
NSString* tmpDepartmentName = (NSString*)ABRecordCopyValue(tmpPerson, kABPersonDepartmentProperty);
[tmpDepartmentName release];
//获取的联系人单一属性:Email(s)
ABMultiValueRef tmpEmails = ABRecordCopyValue(tmpPerson, kABPersonEmailProperty);
for(NSInteger j = 0; j < ABMultiValueGetCount(tmpEmails); j++)
{
NSString* tmpEmailIndex = (NSString*)ABMultiValueCopyValueAtIndex(tmpEmails, j);
[tmpEmailIndex release];
}
CFRelease(tmpEmails);
//获取的联系人单一属性:Birthday
NSDate* tmpBirthday = (NSDate*)ABRecordCopyValue(tmpPerson, kABPersonBirthdayProperty);
[tmpBirthday release];
//获取的联系人单一属性:Note
NSString* tmpNote = (NSString*)ABRecordCopyValue(tmpPerson, kABPersonNoteProperty);
[tmpNote release];
//获取的联系人单一属性:Generic phone number
ABMultiValueRef tmpPhones = ABRecordCopyValue(tmpPerson, kABPersonPhoneProperty);
for(NSInteger j = 0; j < ABMultiValueGetCount(tmpPhones); j++)
{
NSString* tmpPhoneIndex = (NSString*)ABMultiValueCopyValueAtIndex(tmpPhones, j);
[tmpPhoneIndex release];
}
CFRelease(tmpPhones);
}
//释放内存
[tmpPeoples release];
CFRelease(tmpAddressBook);
}
ios获取联系信息
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。