将值分配给 NSDictionary 时无法分配给此表达式的结果

Cannot assign to the result of this expression when assigning values to a NSDictionary

我正在尝试实现此处找到的代码:http://developer.couchbase.com/mobile/develop/guides/couchbase-lite/native-api/document/index.html#updating,在 .update 方法中,代码如下:

document = database.documentWithID(u.id)
document.update({ (newRev) -> Bool in

    newRev["a"] = "A"

    return true
}, error: &error)

但是 swift 不允许我将值添加到 newRev 变量中,告诉我我不能分配给表达式的结果。

谁能帮我解决这个错误?

谢谢

在帮助下我自己找到了解决方案,指南中的错误是他们将更新的值附加到 newRev 值,而它应该附加到它的 newRev.properties var.

所以我创建了一个新的 NSDictionary 变量并将其添加到现有变量中。

var properties = [NSObject: AnyObject]()
properties[PROPERTY_DOCUMENT_TYPE] = String(DOCUMENT_TYPE_USERS)

document.update({ (newRev) -> Bool in

    newRev.properties.addEntriesFromDictionary(properties)

        return true

}, error: &error)