title: Realm is creating multiple entries for nested objects on update
body: <p>I'm experiencing trouble understanding how updating objects works in Realm. I'd appreciate help in helping me to understand how updating <strong>nested objects</strong> work and why it doesn't work the way I expect it.</p>
  
  <p>I started using Realm just recently, and here's what I want to use it for: I have a set of key value pairs stored on my server, that serve as localized values for strings used in my iOS app. On app launch every now and then I want to update my strings, so I pull them from the server and store them locally in realm on my iOS device. I want to have only <strong>ONE instance</strong> of those strings on my device. </p>
  
  <p>Here are the classes:</p>
  
  <pre><code>import RealmSwift
  
  public class LocalizedStrings: Object {
     dynamic var id = 1
     dynamic var version: String = ""
     let assets = List&lt;LocalizedString&gt;()
     override public static func primaryKey() -&gt; String? {
         return "id"
     }
  }
  
  public class LocalizedString: Object {
      dynamic var key: String = ""
      dynamic var value: String = ""
  }
  </code></pre>
  
  <p>Here's how I update the LocalizedStrings object:</p>
  
  <pre><code>realm.add(localizedStrings, update: true)
  </code></pre>
  
  <p>Here's how I access my strings:</p>
  
  <pre><code>func getLocalizedString(forKey key: String) -&gt; String {
      var result = key
      try! realm.write {
          let queryResult = realm.objects(LocalizedString.self).filter("key == %@", key)
          // print(queryResult)
          if queryResult.count == 1 {
              result = queryResult[0].value(forKey: "value") as! String
          }
      }
      return result
  }
  </code></pre>
  
  <p>Now, I would expect, that whenever I update my LocalizedStrings, that the <code>localizedStrings.assets</code> list would get updated with new values. But instead, the assets are not updated, the <strong>list reference gets updated</strong> and I end up having multiple instances of the same string, which is not what I would expect from an update function. When I try to access a particular LocalizedString, it turns out there's multiple instances:</p>
  
  <pre><code>(...)
  [19] LocalizedString {
      key = update;
      value = Update;
  },
  [20] LocalizedString {
      key = update;
      value = Update;
  }
  </code></pre>
  
  <p>Perhaps I'm missing something obvious and I would really appreciate if someone could point me in the right direction, so I'd be able to achieve the behavior I'm looking for (which would be having the nested object actually updated, rather than having unnecessary duplicates of my objects). </p>
  
  <p>Thanks!</p>