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

Convert NsNumber, NSDate to String in iOS Swift

Global LocationManager Singleton class iOS Swift