iosswiftckreference

Remove reference object from table - Swift


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.


Solution

  • 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}
            }
        }