I have a question about pointers and making copies to new memory locations. I understand pointers but I am using them in a complex (for me) situation and the results are not what I was expecting.
Let say this. The code below is shorthand for simpler explanations.
So in the code above I created a couple of Arrays and a Dictionary. I added both arrays to the dictionary with key/value. I then created an array to hold everything called mainArray. The last line I want to make a copy of the dict1 so it remains intact with the current values, and the arrays retain there values.
By creating a COPY of the dict1, I have created a new location in memory to store a copy of the dictionary. But will this also make copies of the array pointers inside of the dictionary?
My end result is the mainArray is tied to an NSPopUpButton. The user selects an item and it retrieves the data.
Let say this. The code below is shorthand for simpler explanations.
Code:
NSArray *array1 = alloc/init;
NSArray *array2 = alloc/init
NSMutableDictinary *dict1 = alloc/init;
NSMutableArray *mainArray = alloc/init;
[dict1 setValue:array1 forKey:@"array1String];
[dict1 setValue:array2 forKey:@"array2String];
[mainArray addObject:[dict1 copy];
So in the code above I created a couple of Arrays and a Dictionary. I added both arrays to the dictionary with key/value. I then created an array to hold everything called mainArray. The last line I want to make a copy of the dict1 so it remains intact with the current values, and the arrays retain there values.
By creating a COPY of the dict1, I have created a new location in memory to store a copy of the dictionary. But will this also make copies of the array pointers inside of the dictionary?
My end result is the mainArray is tied to an NSPopUpButton. The user selects an item and it retrieves the data.