我正在使用云套件fetchUserRecordID
功能,但需要首先使用以下代码授权requestApplicationPermission
访问:
func authoriseICloud(){
container.requestApplicationPermission(.PermissionUserDiscoverability) { (status, error) in
guard error == nil else { return }
if status == CKApplicationPermissionStatus.Granted {
// yay!
}
}
}
但是我收到以下错误,Type 'CKApplicationPermissions' has no member 'PermissionsUserDiscoverability'.
有没有人知道如何成功申请权限?
答案 0 :(得分:1)
将以下代码段与Swift 3
一起使用func authoriseICloud(){
let container = CKContainer.default()
container.requestApplicationPermission(CKApplicationPermissions.userDiscoverability, completionHandler:{ status, error in
if status == CKApplicationPermissionStatus.granted {
// yay!
}
})
}
让我知道它是否适合你。