title: How to Implement deep and shallow copy for NSMutableArray in iOS?
body: <p>I am trying to implement deep and shallow copy for NSMutableArray,</p>
  
  <pre><code>self.oldArray =[[NSMutableArray alloc] initWithCapacity:0];
  self.shallowCopy =[[NSMutableArray alloc] initWithCapacity:0];
  self.deepCopy =[[NSMutableArray alloc] initWithCapacity:0];
  
  
  //add object to old Array
  [self.oldArray addObject:@"rooban"];
  [self.oldArray addObject:@"radha"];
  [self.oldArray addObject:@"jesus"];
  [self.oldArray addObject:@"god"];
  
  
  self.shallowCopy=[[NSMutableArray alloc] initWithArray:self.oldArray];
  self.deepCopy=[[NSMutableArray alloc] initWithArray:self.oldArray copyItems:YES];
  
  //deep copy
  NSLog(@"Lenght of the Old Array before: %d",self.deepCopy.count);
  [self.deepCopy removeObject:@"rooban"];
  NSLog(@"Lenght of the Old Array After: %d",self.oldArray.count);
  
  //shallow copy
  NSLog(@"Lenght of the Old Array Before: %d",self.shallowCopy.count);
  [self.shallowCopy removeObject:@"rooban"];
  NSLog(@"Lenght of the Old Array After: %d",self.oldArray.count);
  </code></pre>
  
  <p>the output of this program is,</p>
  
  <p>deep copy :<br/>
  Lenght of the Old Array before: 4<br/>
  Lenght of the Old Array After: 4<br/></p>
  
  <p>shallow copy :<br/>
  Lenght of the Old Array Before: 4<br/>
  Lenght of the Old Array After: 4<br/></p>
  
  <p>I don't know why shallow copy deletion not reflecting to original NSMutableArray.</p>