I'm new to ObjectiveC and Xcode and make mistakes. This bit of code gets a dictionary (myDataPlist) from getAllRecords. I then make a mutable copy of a dictionary (1 record) within (myDataPlist) and decrypt 1 field with it. This works perfectly. I return just that record (mutCopy). This works also. My problem is the original dictionary (myDataPlist) changes. It The record that is decrypted is also decrypted in (myDataPlist). The 2 NSLog(@"%@",myDataPlist) return different results. I must be missing something. Why is (myDataPlist) changing?
Thanks for the help.
-(NSDictionary *)getRecordForKey:(NSString *)key{
NSDictionary *myDataPlist = [self getAllRecords];
NSMutableDictionary *mutCopy = [[myDataPlist valueForKey:key] mutableCopy];
NSArray *keys = [mutCopy allKeys];
NSData *tData = [[NSData alloc]init];
NSLog(@"%@",myDataPlist);
for (int x = 0; x <= [keys count] - 1; x++) {
if (![keys[x] isEqualToString:@"Template"] && ![keys[x] isEqualToString:@"RecNum"]) {
NSMutableArray *myArray = [mutCopy objectForKey:keys[x]];
tData = myArray[1];
NSString *tString = [tData decryptData:tData withKey:self.settingsManager.masterPad];
myArray[1] = tString;
[mutCopy setObject:myArray forKey:keys[x]];
}
}
NSLog(@"%@",myDataPlist);
return mutCopy ;
}