开发者

Set an NSMutableDictionary variable to an NSDictionary

Is it possible to assign an NSD开发者_运维问答ictionary to an NSMutableDictionary? For example,

NSMutableDictionary * root = AppDelegate.data;

where AppDelegate.data is an NSDictionary.


You want something like this, hopefully it explains itself

root = [AppDelegate.data mutableCopy];


NSMutableDictionary *root = [NSMutableDictionary  dictionary];
[root addEntriesFromDictionary:AppDelegate.data];

This'll add all the entries from the immutable NSDictionary to a new mutable NSMutableDictionary

For future reference the Apple API's (this is the NSMutableDictionary entry) contain a lot of useful information on things like this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜