CloudKit: Fetch all records with a certain record type?

后端 未结 6 837
鱼传尺愫
鱼传尺愫 2021-02-05 19:50

I have currently got CloudKit set up in my app so that I am adding a new record using the help of the following code below,

CKRecordID *recordID         


        
6条回答
  •  说谎
    说谎 (楼主)
    2021-02-05 20:32

    Here's the answer in Swift 3.0.

    func myQuery()  {
        let predicate = NSPredicate(value: true)
        let query = CKQuery(recordType: "tableName", predicate: predicate)
    
        publicDatabase.perform(query, inZoneWith: nil) { (record, error) in
    
            for record: CKRecord in record! {
                //...
    
                // if you want to access a certain 'field'.
                let name = record.value(forKeyPath: "Name") as! String                
            }
        }
    }
    

提交回复
热议问题