微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

iCloud - 将 CKQuery 结果发送到 TableView

如何解决iCloud - 将 CKQuery 结果发送到 TableView

我已经编写了这个模型 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

有什么建议吗?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。