Latest 1.0.0
Homepage https://github.com/srxboys/RXGetAddressBook
License MIT
Platforms ios 6.0, requires ARC
Frameworks AddressBookUI, ContactsUI
Authors
  • 获取系统通讯录的名字和电话【srxboys】
  • 亲测 实现 > iOS6

  • POD

     pod 'RXGetAddressBook'

EXAMPLE

    //初始化对象 在viewDidLoad
   __weak typeof(self)weakSelf = self;

    //iOS >=iOS9
    _objct10 = [[RXAddressiOS10 alloc] init];
    _objct10.complete = ^(BOOL status, NSString * phoneNum, NSString * nameString) {
        if(status) {
            weakSelf.phoneLabel.text = phoneNum;
        }

        weakSelf.nameLabel.text = nameString;
    };

    //iOS < iOS9
    _objct9 = [[RXAddressiOS9 alloc] init];
    _objct9.complete = ^(BOOL status, NSString * phoneNum, NSString * nameString) {
        if(status) {
            weakSelf.phoneLabel.text = phoneNum;
        }
        weakSelf.nameLabel.text = nameString;
    };

    //调用通讯录 方法
    if(iOS9Later) {
        //iOS >=iOS9
        [_objct10 getAddress:self];
    }
    else {
        //iOS < iOS9
        [_objct9 getAddress:self];
    }

提供判断是否为11位的手机号正则表达式判断

    ///是否为手机号码
    - (BOOL)checkPhoneNum:(NSString *)str {
        NSString *regex = @"1[0-9]{10}";

        NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];

        BOOL isMatch = [pred evaluateWithObject:str];
        return isMatch;
    }

效果图(如下):


RXGetAddressBook

(Thanks)谢谢观看!!!!!

Latest podspec

{
    "name": "RXGetAddressBook",
    "version": "1.0.0",
    "summary": "Get the name and phone number of the system address book.",
    "homepage": "https://github.com/srxboys/RXGetAddressBook",
    "license": "MIT",
    "authors": {
        "srxboys": "[email protected]"
    },
    "platforms": {
        "ios": "6.0"
    },
    "source": {
        "git": "https://github.com/srxboys/RXGetAddressBook.git",
        "tag": "1.0.0"
    },
    "source_files": "RXAddressBook/*.{h,m}",
    "frameworks": [
        "AddressBookUI",
        "ContactsUI"
    ],
    "requires_arc": true
}

Pin It on Pinterest

Share This