title: Getting RLMException: Can't set primary key property 'id'
body: <p>I have a bunch of methods saving camera names related to a video recording asynchronously in Realm database. </p>
  
  <p>My model:</p>
  
  <pre><code>/**
   Realm object for saving the camera names used
   to record clip videos
  */
  public class RMCamera: Object {
  
      dynamic var id = ""
      dynamic var name = ""
  
      override public class func primaryKey() -&gt; String {
         return "id"
      }
  
  }
  </code></pre>
  
  <p>The method saving the camera's in Realm:</p>
  
  <pre><code>/**
   Saves camera names for offline usage after deleting
   all current entries first.
  
   - parameter cameraNames: An array of string with the camera names to save
   */
  public func saveCameraNames(cameraNames: [String]) {
  
      logv(" Saving camera names...")
  
      concurrentQueueBg.async {
  
          let realm = try! Realm()
  
          self.deleteCamerasFromRealm(realm)
  
          cameraNames.forEach { camera in
  
              let offlineCamera = RMCamera(value: ["id": NSUUID().UUIDString, "name": camera])
  
              do {
                  try realm.write {
                      realm.add(offlineCamera)
                  }
              } catch {
                  loge("Error adding offline camera")
              }
          }
  
      }.notify(.Main) {
          logv("✅ Camera names saved!")
      }
  }
  </code></pre>
  
  <p>And the method that first purges all camera entries from Realm:</p>
  
  <pre><code>/**
   Deletes all camera names saved in the passed Realm
  
   - parameter realm: A Realm database instance to use
   */
  func deleteCamerasFromRealm(realm: Realm) {
  
      let cameras = realm.objects(RMCamera)
  
      try! realm.write {
          realm.delete(cameras)
      }
  }
  </code></pre>
  
  <p>The problem is that every once in a while I am getting errors like this one:</p>
  
  <p><code>Can't set primary key property 'id' to existing value '572cb087b974c25b01fa40c1'.</code></p>
  
  <p>Any ideas what might be actually going wrong? I really don't think I am getting collisions from UUID generation.</p>