-
StackOverflow 文件
-
iOS 教程
-
聯絡框架
-
授權聯絡人訪問
匯入框架
迅速
import Contacts
Objective-C
#import <Contacts/Contacts.h>
檢查可訪問性
迅速
switch CNContactStore.authorizationStatusForEntityType(CNEntityType.Contacts){
case .Authorized: //access contacts
case .Denied, .NotDetermined: //request permission
default: break
}
Objective-C
switch ([CNContactStore authorizationStatusForEntityType:CNEntityType.Contacts]){
case CNAuthorizationStatus.Authorized:
//access contacts
break;
case CNAuthorizationStatus.Denied:
//request permission
break;
case CNAuthorizationStatus.NotDetermined:
//request permission
break;
}
請求許可
迅速
var contactStore = CKContactStore()
contactStore.requestAccessForEntityType(CKEntityType.Contacts, completionHandler: { (ok, _) -> Void in
if access{
//access contacts
}
}