I have been trying to understand the difference between deep and shallow copy by following the link: Difference
What i did :
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
tempArray=[[NSMutableArray alloc] initWithObjects:@"A",@"B",@"C",@"D",@"E",@"F",@"G", nil];
shallowArray=[[NSMutableArray alloc] initWithArray:tempArray copyItems:NO];
deepArray=[[NSMutableArray alloc] initWithArray:tempArray copyItems:YES];
}
- (IBAction)testShallowDeep:(id)sender {
[tempArray removeObjectAtIndex:0];
NSLog(@"ShallowArray should get changed==%@",shallowArray);
NSLog(@"DeepArray should remain Same===%@'",deepArray);
}
However when i checked the logs both are coming same as temp array. Anybody can explain this concept with above example. According to my understanding Shallow Array should get changed and element 'A' should be removed from it and Deep Array should remain same as temp Array.