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.
精彩评论