Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copying the contents of an NSMutableDictionary into another NSMutableDictionary?

I have an NSMutableDictionary each element of which is another dictionary. What is the best way I can copy its contents into another NSMutableDictionary? I've tried using:

firstDictionary = [NSMutableDictionary dictionaryWithDictionary:secondDictionary];

However not sure if this is the best way to do it.

like image 352
NSExplorer Avatar asked Jan 05 '11 02:01

NSExplorer


1 Answers

You can also jump between mutable and non-mutable dictionaries using copy and mutableCopy.

- (void) someFunc:(NSMutableDictionary *)myDict {
    NSDictionary *anotherDict = [myDict copy];
    NSMutableDictionary *yetAnotherDict = [anotherDict mutableCopy];
}
like image 187
Jay Imerman Avatar answered Oct 20 '22 00:10

Jay Imerman