[__NSCFDictionary setObject:forKey:]: mutating method sent to immutable object'

let dic = NSMutableDictionary()

dic.setValue("", forKey:"")

-[__NSCFDictionary setObject:forKey:]: mutating method sent to immutable object'


明明定义了NSMutableDictionary,但是使用setValue是依旧报错


解决方法-》

let dic = ["":"","":""] as [NSObject:AnyObject]

let newDic = NSMutableDictionary(dictionary: dic, copyItems:true)

newDic.setValue("", forKey:"")

你可能感兴趣的:([__NSCFDictionary setObject:forKey:]: mutating method sent to immutable object')