我正在使用下面的CKOperation
通过电子邮件查找用户记录。每次我运行代码时,它总是返回发现为nil的用户。我知道电子邮件地址是正确的。你知道我可能在哪里出错或者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
})