Append existing object to Realm List
<p>I have <code>CatalogItem</code> objects with primary key in my code.
Realm is throwing an error during write in the following code:</p>

<pre><code>class CartItem: Object {
    dynamic var id: Int = 0
    dynamic var item: CatalogItem!
    dynamic var amount: Int = 0

    convenience required init(id: Int, item: CatalogItem, amount: Int) {
        self.init()
        self.id = id
        self.item = item
        self.amount = amount
    }
}

class Cart: Object {

    var items = List&lt;CartItem&gt;()

    func addItem(item: CatalogItem) {
        let realm = try! Realm()
        let newItem = CartItem(id: item.id, item: item, amount: 1)
        do {
            try realm.write {
                items.append(newItem)
            }
        } catch let e {
            handleError(e)
        }
    }
}
</code></pre>

<p>Error:</p>

<pre><code>'RLMException', reason: 'Can't set primary key property 'id' to existing value '352'.'
</code></pre>

<p>I expect Realm to reference existing <code>CatalogItem</code> but it looks like it's trying to add another one.
Is there a way to implement this kind of relationship?
Note: all objects are stored in one realm.</p>