我正在使用CKOperation
以下内容通过他们的电子邮件查找用户记录。每次我运行代码时,它总是将用户的发现返回为零。我知道电子邮件地址是正确的。你知道我哪里可能出错或者 CloudKit 是否有错误?
谢谢
let operation = CKDiscoverUserInfosOperation()
operation.qualityOfService = .UserInitiated
operation.emailAddresses = ["email@me.com"]
operation.discoverUserInfosCompletionBlock = { [unowned self] (userInfoString, userInfoID, error) in
if error != nil {
dispatch_async(dispatch_get_main_queue()) {
//Update UI Here
let alert = UIAlertView(title: "Error", message: "Unable to fetch data. Please try again later.", delegate: self, cancelButtonTitle: "Okay").show()
}
} else {
print("Info string: \(userInfoString)")
print("Info: \(userInfoID)")
}
}
container.addOperation(operation)
我还在以下内容中添加了这个viewDidLoad
:
CKContainer.defaultContainer().requestApplicationPermission(CKApplicationPermissions.UserDiscoverability,
completionHandler: {
applicationPermissionStatus, error in
})