How to copy NSMutableDictionary values into the another NSMutableDictionary in iPhone?

Pugalmuni picture Pugalmuni · Jan 28, 2011 · Viewed 14.1k times · Source

I want to copy a NSMUtableDictionary values into the another NSMutableDictioary. How can i do that?

Here my code is,

 PersonClass.h file:

 NSMutableDictionary *tempDictionary;
 @property (nonatomic, retain) NSMutableDictionary *tempDictionary;

 PersonClass.m
 @synthesize tempDictionary; 

 tempDictionary = [[NSMutableDictionary alloc] init];

-(PersonClass *) initWithPerson:(NSMutableDictionary *) feedDictionary
{
     // get all the values in feedDictionary.

     //Now i want copy of the details from feedDictionary into the tempDictionary

           tempDictionary = feedDictionary; // Doesn't copy.
}

I want to access the tempDictionary values to the person class. SO how can i copy from feedDictionary to the tempDictionary. Please help me out.

Thanks.

Answer

Fran Sevillano picture Fran Sevillano · Jan 28, 2011

How about this?

tempDictionary = [[NSMutableDictionary alloc]initWithDictionary:feedDictionary];

Cheers