我如何将NSDictionary转换为NSMutableDictionary?

我有一个现有的NSDictionary有:

{ "charts_count" = 2; "created_at" = "2010-04-12T16:37:32Z"; exchange = NASDAQ; "followers_count" = 259; id = 8404; industry = "<null>"; "messages_count" = 1436; ric = "GRPN.O"; sector = "<null>"; symbol = GRPN; title = Groupon; "updated_at" = "2011-09-05T04:17:56Z"; } 

我怎样才能把这些内容,并把它放到一个新的NSMutableDictionary?

使用-mutableCopy

 NSDictionary *d; NSMutableDictionary *m = [d mutableCopy]; 

请注意, -mutableCopy返回id (Swift中的Any ),所以您将要分配/转换为正确的types。 它创build了原始字典的浅表副本。

在Swift的情况下

 var tempDic: NSMutableDictionary = yourDictionary.mutableCopy() as NSMutableDictionary