获取通讯录

一、在工程中添加AddressBook.framework和AddressBookUI.framework

二、获取通讯录

1、在infterface中定义数组并在init方法中初始化

1 NSMutableArray *addressBookTemp;
2  
3 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
4 {
5     addressBookTemp = [NSMutableArray array];
6 }
2、定义一个model,用来存放通讯录中的各个属性

新建一个继承自NSObject的类,在.h中

01 @interface TKAddressBook : NSObject {
02     NSInteger sectionNumber;
03     NSInteger recordID;
04     NSString *name;
05     NSString *email;
06     NSString *tel;
07 }
08 @property NSInteger sectionNumber;
09 @property NSInteger recordID;
10 @property (nonatomic, retain) NSString *name;
11 @property (nonatomic, retain) NSString *email;
12 @property (nonatomic, retain) NSString *tel;
13  
14 @end
在.m文件中进行synthesize
1 @implementation TKAddressBook
2 @synthesize name, email, tel, recordID, sectionNumber;
3  
4 @end

3、获取联系人

在iOS6之后,获取通讯录需要获得权限

01     //新建一个通讯录类
02     ABAddressBookRef addressBooks = nil;
03  
04     if ([[UIDevice currentDevice].systemVersion floatValue] >= 6.0)
05  
06     {
07         
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值