0

この特定の ID -MqXU-kKVhl5ef10XDでこのフィールドmyIdを照会するにはどうすればよいですか

役職:

let database = CKContainer(identifier: "iCloud.com.myCo.myApp").publicCloudDatabase

let record = CKRecord(recordType: "Sample")

record["myId"] = "-MqXU-kKVhl5ef10XD"

database.save(record) { (ckRecord, error) in
})

クエリ:

let predicate = NSPredicate()
    
let query = CKQuery(recordType: "Sample", predicate: predicate)
    
database.perform(query, inZoneWith: nil) { (ckRecords, error) in
    if let err = error { return }

    guard let records = ckRecords else { return }

    guard let record = records.first else { return }

    guard let myId = record.value(forKey: "myId") as? String else { return }
    print(myId)
})
4

1 に答える 1