title: REALM reason: 'Attempting to modify object outside of a write transaction - call beginWriteTransaction on an RLMRealm instance first.'
body: <p>I am getting an error when trying to modify a realm object.</p>
  
  <p>It is a simple class and there is actually only one record.</p>
  
  <pre><code>class User: Object{
  
      @objc dynamic var id = UUID().uuidString
      @objc dynamic var name:String  = ""
      @objc dynamic var email:String = ""
      .....
  
      static func getInfo() -&gt; User? {
          do {
              let realm = try Realm()
              return realm.objects(User.self).first
          } catch {
              return nil
          }
      }
  
  }
  </code></pre>
  
  <p>I call the data:</p>
  
  <pre><code>var user = User.getInfo()
  </code></pre>
  
  <p>And now when I try to modify it I get the following error.</p>
  
  <pre><code>user.name = "test"
  </code></pre>
  
  <p>*** Terminating app due to uncaught exception 'RLMException', reason: 'Attempting to modify object outside of a write transaction - call beginWriteTransaction on an RLMRealm instance first.'</p>
  
  <p>what am I doing wrong? Thanks.</p>
  
  <p>Thanks.</p>