Facing issue with NSMutableDictionary
,
I have one main mutable dictionary, which is dictMain
,
Taken another mutable dictionary, which is dictSubMain
,
Declaration as below in ViewController.m file,
@interface ViewController ()
{
NSMutableDictionary *dictMain;
NSMutableDictionary *dictSubMain;
}
Now I have some values filled in dictMain
initially from viewDidLoad method.
I have one another method, in which very firstly I am assigning dictMain
to another mutable dictionary dictSubMain
then I made some changes in dictSubMain
but the issue is whatever changes I am making in dictSubMain
that same changes reflecting on dictMain
also. I don't want to make any changes in dictMain
.
Below is my code,
-(void)addRowsInTable:(NSInteger)index
{
dictSubMain = [[NSMutableDictionary alloc] initWithDictionary:dictMain];
NSMutableArray *tmpArray = [[NSMutableArray alloc] init];
NSMutableDictionary *tmpDic = [[NSMutableDictionary alloc] init];
[tmpDic setObject:self.btnTTNumDent.currentTitle forKey:kNUMDENT_T];
[tmpDic setObject:self.btnTTSizeDent.currentTitle forKey:kSIZEDENT_T];
[tmpArray addObject:tmpDic];
[[[dictSubMain valueForKey:kDATA] objectAtIndex:index] setObject:tmpArray forKey:kTABLE];
}
Can anyone help me out to resolve it! Thanks in advance.