title: NSMutableArray is affecting the another NSMutableArray?
body: <p>I have two <code>NSMutableArray</code>s, both getting the same data.  My problem is that when I assign the same data to both the mutable arrays from different dictionaries and perform operations on one <code>NSMutableArray</code>, it is affecting both arrays.</p>
  
  <p>When I perform operations like <code>replaceObjectAtIndex:WithObject:</code>, the first time, the array is not affected but when the second replace is called both arrays have the replaced value. I think it is a reference issue. </p>
  
  <p>Does anyone have a solution to this?</p>
  
  <p>Name of the <code>NSMutableArrays</code> is <code>helper.urlsRecording</code> and <code>helper.holdingArr</code>.</p>
  
  <pre><code>NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
  NSMutableDictionary *dict2 = [[NSMutableDictionary alloc] init];
  [dict setValue:outputFileURL forKey:@"URL"];
  [dict setValue:@"1" forKey:@"index"];
  [dict2 setValue:outputFileURL forKey:@"URL"];
  [dict2 setValue:@"1" forKey:@"index"];
  [helper.urlsRecording addObject:dict];
  [helper.holdingArr addObject:dict2];
  
  
  [helper.urlsRecording replaceObjectAtIndex:button.tag withObject:urlAr];//When this called second time, both the arrays is effected(helper.urlsRecording as well as helper.holdingArr).
  </code></pre>
  
  <p>How can I prevent the copying of the reference to another array?</p>
  
  <p>Button Click:</p>
  
  <pre><code>if([button isSelected] == NO){
  
       NSLog(@"Url Recording : %@",helper.urlsRecording);
       [[helper.urlsRecording objectAtIndex:button.tag] removeObjectForKey:@"URL"];
       button.selected = YES;
       NSLog(@"Url Recording : %@",helper.urlsRecording);
  }
  else{
       [helper.urlsRecording replaceObjectAtIndex:button.tag withObject:[helper.holdingArr objectAtIndex:button.tag]];
       button.selected = NO;
       NSLog(@"Url Recording : %@",helper.urlsRecording);
  
   }
  </code></pre>
  
  <p>Note: <code>NSMutableArray</code> is defined globally in a class to access.</p>