I have an iPhone application that pulls some JSON data from a server and then parses it into an array of dictionaries which contains sub-arrays and sub-dictionaries.
Right now I have this stored in an ivar timeTable
then copying it to filteredTimetable
before looping through filteredTimetable
and removing the objects I don't need.
The problem I am having is when I try restore the array so it can be filtered again. The objects that have been removed previous from the copied NSArray are removed from the original NSArray too.
filteredTimeTable = [[NSMutableArray alloc] initWithArray:timeTable copyItems:YES];
I assume this is because filteredTimeTable
is simply storing a pointers to the objects in timeTable
rather than copying the memory.
Here is an example of my data structure:
[
{"time":"09:00",
"events": [
{ "module":"COMP319", "type":"lecture", "room":"BROD-108:80" }
{ "module":"COMP320", "type":"lab", "room":"BROD-LT" }
]},
When I remove a module that is no longer required I can't restore the element.
So is there anyway to do a full copy including all the sub-objects?