setValue(value, forKey) 以某种方式改变了 Realm 中的整个数组

setValue(value, forKey) somehow changes the whole array in Realm

我尝试更改我创建的对象中的值。但是不知何故,在这个简单的操作之后,整个数组正在编辑。

这是 Swift 4.2,我正在使用 Realm 和 iOS 12.4。

let index = indexes[i].map { String([=10=]) }.joined(separator: "")
//index is "00"

let obj = object[index] 
print(object)

let key = (o.value)["values"].array![Int(key.0)!]
obj?.setValue(res, forKey: key["prop_name"].string!) //example data provided in screenshot

print("Adding property " + (key["prop_name"].string! ) + " with value '" + (key["value"].string!) + "' = " + res) //in example I add property 'number' with value = 1
print(object)

我希望有一个 Object 会改变。

可怜的我。

Realm 链接 Object 您之前创建的数组。

所以我需要创建不同的对象并将它们放入这个数组中。我每次都编辑相同的Object