I made a request on 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, however Realm throws 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 have seen, Realm updates the instances of your requests when you have modifications to the registry. But I do not want the registry to be updated until it sends the data to the server.