Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

438
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!