-3
ABAuthorizationStatus status = ABAddressBookGetAuthorizationStatus();
if (status == kABAuthorizationStatusNotDetermined) {
NSLog(@"未知");
ABAddressBookRef addressBook = ABAddressBookCreateWithOptions(NULL,NULL);
ABAddressBookRequestAccessWithCompletion(addressBook, ^(bool granted, CFErrorRef error) {
if (granted) {
NSLog(@"ok");
} else {
NSLog(@"nonono,always here");
}
CFRelease(addressBook);
});
}
如果我創建一個新項目,此代碼將編譯。ABAddressBookRequestAccessWithCompletion不警告,始終沒有授予
但在我的當前項目中沒有給出警報和構建失敗,出現以下錯誤 kABAuthorizationStatusNotDetermined狀態,並授予=零
模擬器8,它會顯示警報;但模擬器9,不警報;在模擬器9上的 –
,不警報並且總是記錄「nonono,總是在這裏」; –
您需要使用CNContactStore在iOS 9上獲取聯繫人。此鏈接可以幫助您https://gist.github.com/willthink/024f1394474e70904728 – riowww