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.


            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

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

Saved Image in document directory and save path in coredata not able to fetch the image file iOS swift