I create two NSMutableDictionary: dictionary1 and dictionary2. In the first dictionary I store some array object having there keys. And in the second dictionary I store the object of first dictionary with the key like this:
int page = 1;
[dictionary2 setObject:dictionary1 forKey:[NSString stringWithFormat:@"%d",page]];
[dictionary1 removeAllObjects];
but at the time of retrieve of the object i do like this
dictionary1 = [dictionary2 valueForKey:[NSString stringWithFormat:@"%d",page]];
NSLog(@"dictionary1 %@", dictionary1);`
Then it gives null value. I don’t know what mistake I do.
After you add
dictionary1todictionary2, you are removing all of the objects.This is the same dictionary that is in dictionary2 (it does not create a copy), therefore you are removing the objects from it as well.
You need to remove the line
[dictionary1 removeAllObjects];.Then, since you are done with
dictionary1at this point, you can either remove the reference to it or set to a nice new shiny dictionary which is ready to use: