林之外定义,我想这样的功能中填写词典:不能访问字典的功能
var categories = [String:String]()
func addCategory (cat: String, symptomID: String) ->() {
categories[cat] = symptomID
}
但我不断收到Cannot assign to the result of this expression
。
考虑到Swift Documentation我不明白为什么这不起作用。
有趣的是,在函数中定义字典并不会给我这个错误。
你什么时候调用这个函数?你的代码没有任何错误。 –
我想我找到了问题。我在一个显然不工作的结构中使用它 – Rico