我收到错误:“类型'CKDatabase'的值没有成员'fetchUserRecordIDWithCompletionHandler'。”它是从最新版本的Xcode还是swift 3中删除的?
func fetchUserRecords()
{
let publicDB = CKContainer.default().publicCloudDatabase
publicDB.fetchUserRecordIDWithCompletionHandler { (userID, error) -> Void in
if let userID = userID {
let reference = CKReference(recordID: userID, action: .None)
let predicate = NSPredicate(format: "creatorUserRecordID == %@", reference)
let query = CKQuery(recordType: "Location", predicate: predicate)
CKContainer.default().publicCloudDatabase.perform(query, inZoneWith: nil){
(records, error) in
if error != nil {
print("error fetching user records: \(error)")
completion(error as NSError?, nil)
} else {
print("found user records")
completion(nil, records)
guard let records = records else {
return
}
for record in records
{
//delete records
}
}
}
}
}
}
答案 0 :(得分:2)
Swift 3更改了许多函数调用的名称。新功能签名是
func fetchUserRecordID(completionHandler: @escaping (CKRecordID?, Error?) -> Void)
rmaddy报告该函数是CKContainer
的函数,而不是CKDatabase
。