//使用第三方框架:RHAddressBook,在github上搜索,按照要求把工程添加到当前项目
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
//1.授权
RHAuthorizationStatus status = [RHAddressBook authorizationStatus];
if (status == RHAuthorizationStatusNotDetermined) {
RHAddressBook *book = [[RHAddressBook alloc]init];
[book requestAuthorizationWithCompletion:^(bool granted, NSError *error) {
//localizedDescription 错误信息 的字符串
if (error) {
NSLog(@"%@",error.localizedDescription);
}
if (granted) {
NSLog(@"授权成功1");
}else{
NSLog(@"授权失败");
}
}];
}
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
RHAddressBook *book = [[RHAddressBook alloc]init];
for (RHPerson * objc in [book people]) {
NSLog(@"%@",[objc class]);
}
NSLog(@"%@",[book people]);
}
@end