I have an existing NSDictionary that has:
{
\"charts_count\" = 2;
\"created_at\" = \"2010-04-12T16:37:32Z\";
exchange = NASDAQ;
\"followers_c
Try this in swift 3
let mutableDic: NSMutableDictionary = (yourDictionary as! NSDictionary).mutableCopy() as! NSMutableDictionary
In case of Swift
var tempDic: NSMutableDictionary = yourDictionary.mutableCopy() as NSMutableDictionary
Use -mutableCopy
.
NSDictionary *d;
NSMutableDictionary *m = [d mutableCopy];
Note that -mutableCopy
returns id
(Any
in Swift) so you will want to assign / cast to the right type. It creates a shallow copy of the original dictionary.
NSMutableDictionary *newInfo = [[NSMutableDictionary alloc] init];
[newInfo setDictionary:info];
Also works, since you are setting the dictionary not appending. You can also use:
[newInfo addEntriesFromDictionary:info];
for the same effect and to append to existing content.