Coder Social home page Coder Social logo

xutongle / rxgetaddressbook Goto Github PK

View Code? Open in Web Editor NEW

This project forked from srxboys/rxgetaddressbook

0.0 1.0 0.0 963 KB

🐱获取系统通讯录的名字和电话 / Get the name and phone number of the system address book【srxboys】

License: MIT License

Objective-C 96.30% Ruby 3.70%

rxgetaddressbook's Introduction

RXGetAddressBook

  • 获取系统通讯录的名字和电话【srxboys】
  • 亲测 实现 > iOS6

POD

     pod 'RXGetAddressBook'
     
     //info.plist 设置
     //xml:
     <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<string>需要通讯录权限</string>
</plist>
     //直观
Privacy - Contacts Usage Description  ->  string : 需要通讯录权限

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)谢谢观看!!!!!

rxgetaddressbook's People

Contributors

srxboys avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.