Remove reference object from table - Swift

351 views Asked by At

I am having issues to remove a reference relationship from a table.

I have the following user2reference added to the following table.

enter image description here

And I want just to remove this reference relationship from the table. It should look like this:

enter image description here

Tried to store an empty string or an CKReference with an empty recordName but does not work.

2

There are 2 answers

0
Yury On BEST ANSWER

Try this:

database.fetchRecordWithID(CKRecordID(recordName: "user2reference"))
    {
        record, error in
        if let record = record
        {
            record.setObject(NSString(string: ""), forKey: "recordName")
            self.database.saveRecord(record) {_ in}
        }
    }
0
powertoold On

Or you can just do

record["user2reference"] = nil

After fetching the record from CloudKit