我已经编写了这个模型 swift 文件类,并在没有错误的情况下运行,但没有将任何记录字段数据填充到 resultsValueArray 数组中。我在这里想念什么?
import Foundation
import CloudKit
class TeamDataLoad {
let container = CloudKit.CKContainer(identifier: "ICloud.Brian-Naszradi.RosterTableView")
func rosterQuery(tName: String) -> Array<Any> {
var resultsValueArray = [] as Array
let teamPredicate = NSPredicate(format: "teamName == %@", tName)
print("teamPredicate: ", teamPredicate)
let query = CKQuery(recordType: "team", predicate: teamPredicate)
print("query: ", query)
let qOperation = CKQueryOperation.init(query: query)
qOperation.resultsLimit = 25
qOperation.recordFetchedBlock = { record in
let results = [record.value(forKey: "player") as! String]
print("player is:", results)
resultsValueArray.append(contentsOf: results)
} //recordFetchedBlock
qOperation.queryCompletionBlock = { cursor, error in
let queryCount = resultsValueArray.count
} // qOperttion queryCompletionBlock
CKContainer.default().publicCloudDatabase.add(qOperation)
return resultsValueArray
} //rosterQuery func
} // TeamDataLoad class
有什么建议么?