In my application I need to create a copy of NSMutableArray
. Currently I am using mutableCopy
method. But when I modify the copied array the original one is also modified. Please tell me How to create a new copy NSMutableArray
.
Here is the code
delegate = (AppDelegate *)[[UIApplication sharedApplication]delegate];
self.mainImagesArray = [[NSMutableArray alloc]initWithArray:[delegate.arrayForCarCaptureImages mutableCopy]];
and here i am modifying
UIImage *filteredImage =[[[[self.mainImagesArray objectAtIndex:i]valueForKey:valueVheck] objectAtIndex:j] copy];
filteredImage =[filteredImage brightness:(1+sliderValue-0.5)];
[[[self.mainImagesArray objectAtIndex:i]valueForKey:valueVheck]removeObjectAtIndex:j];
[[[self.mainImagesArray objectAtIndex:i] valueForKey:valueVheck]insertObject:filteredImage atIndex:j];
After execution the arrayForCarCaptureImages also modified automatically.