I want to add an object to favorites. In that case, when users press a button to add an object to favorites, the object will be saved to realm. then he press a button to remove the object from favorites and it will be removed. Afterwards, he press the button to save again, it should be saved again. Is it available?
When I pressed the save button twice, it says
Terminating app due to uncaught exception 'RLMException', reason: 'Object has been deleted or invalidated.'
The codes are like below.
func delete() {
realm.write({
self.realm.delete(obj)
})
}
func save() {
realm.write({
self.realm.add(obj, update: false)
})
}