通讯录(框架实现)

//使用第三方框架: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

原文地址:https://www.cnblogs.com/tangranyang/p/4656143.html