Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

440
Vistas
REALM reason: 'Attempting to modify object outside of a write transaction - call beginWriteTransaction on an RLMRealm instance first.'

I am getting an error when trying to modify a realm object.

It is a simple class and there is actually only one record.

class User: Object{

    @objc dynamic var id = UUID().uuidString
    @objc dynamic var name:String  = ""
    @objc dynamic var email:String = ""
    .....

    static func getInfo() -> User? {
        do {
            let realm = try Realm()
            return realm.objects(User.self).first
        } catch {
            return nil
        }
    }

}

I call the data:

var user = User.getInfo()

And now when I try to modify it I get the following error.

user.name = "test"

*** Terminating app due to uncaught exception 'RLMException', reason: 'Attempting to modify object outside of a write transaction - call beginWriteTransaction on an RLMRealm instance first.'

what am I doing wrong? Thanks.

Thanks.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

user is a Realm instance. Any modifications to user need to be within a realm.write block.

try! realm.write {
    user.name = "test"
}
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda