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



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

document = database.documentWithID(u.id)
document.update({ (newRev) -> Bool in
    newRev["a"] = "A"
    return true
}, error: &error)

,但是Swift并没有让我将值添加到NewRev变量中,告诉我我无法分配到Expresion的结果。

有人可以帮助我解决这个错误吗?

谢谢

在帮助我自己找到解决方案的情况下,指南中的错误是它们将更新的值附加到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)

最新更新