在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
通讯录的访问步骤一般如下:
class ViewController: UIViewController { //1.创建通讯录对象ABAddressBookRef。 let addressBook: ABAddressBook = ABAddressBookCreateWithOptions(nil, nil).takeRetainedValue() override func viewDidLoad() { super.viewDidLoad() //2.获得用户授权访问通讯录 ABAddressBookRequestAccessWithCompletion(addressBook){isAccess, error in if isAccess { //操作 self.getAddressBookInfos() } } } func getAddressBookInfos() { if ABAddressBookGetAuthorizationStatus() == .Authorized { //3.查询联系信息 var arr = ABAddressBookCopyArrayOfAllPeople(self.addressBook).takeRetainedValue() for record in arr as NSArray { //do something... } } } }
|
请发表评论