Modified in memory, not saved to disk, saved to disk after user confirmation

RealmSwift v3.18.0

We have a scenario where we read a model from a local database, and then the user edits the model data. The user can manually click to save to the local database, and the user can also choose not to save the data in the local database

I try to
Modifying an object without a write transaction results in an RLMException
“Attempting to modify object outside of a write transaction - call beginWriteTransaction on an RLMRealm instance first.”

That’s correct behavior. If you load an object from Realm, it cannot be modified outside a write transaction.

There are a few way’s to handle it; only modify the object when the user clicks ok for example or, you can create an object that is not managed by realm (as an in memory object) and save it when needed.

let standaloneModelObject = MyModel(value: persistedModelObject)

We can’t really provide better direction without more information about your use case.