Change the dictionary Value in an array iOS swift
Solution:
In NSDictionary you cannot be able to change the value.If you can convert the NSDictionary to NSMutableDictionary then you can change the value in it.
self.dataArray.replaceObject(at: 0, with: NSDictionary(dictionary: mute))
In NSDictionary you cannot be able to change the value.If you can convert the NSDictionary to NSMutableDictionary then you can change the value in it.
var dic = dataArray.object(at: 0) as! NSDictionary
let mute = NSMutableDictionary()
mute.addEntries(from: dic as! [AnyHashable : Any])
mute.setValue("value", forKey: "keyValue")
self.dataArray.replaceObject(at: 0, with: NSDictionary(dictionary: mute))
Comments
Post a Comment