I have declared an NSMutableArray *arrAllRecordsM
and am trying to add NSMutableDictionary *dicRecordM
to it using addObject
. The dicRecordM
gets added to arrAllRecordsM
but on doing [dicRecordM removeAllObjects]
it sets to nil in arrAllRecordsM
. Below is the code, please help me fix it.
self.arrAllRecordsM = [NSMutableArray array];
self.dicRecordM = [NSMutableDictionary dictionary];
// Some Method
[self.dicRecordM setObject:@"Test" forKey:@"ADDRESS"];
[self.arrAllRecordsM addObject:self.dicRecordM];
// Value: Test
NSLog(@"Value: %@", [[self.arrAllRecordsM objectAtIndex:0] valueForKey:@"ADDRESS"]);
[self.dicRecordM removeAllObjects];
// Value: null
NSLog(@"Value: %@", [[self.arrAllRecordsM objectAtIndex:0] valueForKey:@"ADDRESS"]);