0
I made a request in the local database and received an array with the data. Then I run the array with looping for, looking for an object with a specific id, when locating the object I try to update a property, but Realm triggers the following error:
*** Terminating app due to uncaught Exception 'Rlmexception', Reason: 'Attempting to Modify Object Outside of a write transaction - call beginWriteTransaction on an Rlmrealm instance first.'
Code that generates the error:
var arrayObjects: Results<MyModel>?
viewDidLoad(){
arrayObjects = managerLocalDB.getAllData()
}
// Depois ...
func registerNewStatus(status: Bool, id: Int) {
for abrTmp in arrayObjects!{
if abrTmp.id == id{
abrTmp.selecionado = status
}
}
}
From what I’ve seen, Realm updates the instances of your requests by having modifications to the record. But I don’t want the record to be updated until I send the data to the server.
I came to the same conclusion after researching a little, but you already said the answer!! Thank you Lucas!
– Tiago Amaral