CKRecord fetch return 1 record with empty RecordID

212 views Asked by At

enter image description here

Record from iCloud container is fetched, but there is no RecordID. At the same time in the panel on the site, I see it. I tried to extract the record from another application, I registered the necessary container in the settings - and it was extracted without error.

I do not understand - this is a bug Xcode? After all, the extraction code is identical in the second application, where everything works. And in the debugger at the bottom left you can see that RecordID is not empty.

Code:

privateDatabase.perform(query, inZoneWith: nil) { (results, error) -> Void in
    if error != nil {
        print(error!.localizedDescription)
        result(false)

    } else if results != nil, results!.count > 0, let me = results?[0] {
        let RN = (me[.recordID] as! CKRecord.ID).recordName  

Error:

Thread 2: Fatal error: Unexpectedly found nil while unwrapping an Optional value

Variables View Console:

_recordName __NSCFString * @"UA-kuka-2018-11-16 11:27:59" 0x00000001c0644320

1

There are 1 answers

2
rmaddy On

The proper way to get the recordID of a CKRecord is to use the recordID property.

Assuming me is actually a CKRecord:

let RN = me.recordID.recordName