Reputation: 247
I have my UITableView
data organized such that the sections of the table are the array elements of a NSMutableArray
. Each element itself is a NSMutablearray
of NSMutableDictionary
, representing the row of each section and the data for each row.
When I create this, I load all the data and create each section's NSMutableArray, then add them one at a time to the "outer" NSMutableArray
. I reference the rows by:
[[[objData objectAtIndex:indexPath.section] objectAtIndex:indexPath.row] objectForKey:@"name"]
and have had no problems doing this. I think the advantage here is I can have a variable number of sections, which I need, and a variable number of rows in each section, also a requirement.
I do, however, get an error when I try to add a row to a section.
[[objData objectAtIndex:0] addObject:[[NSMutableDictionary alloc] initWithObjectsAndKeys: objectID,@"id",nameVar,@"name",nil]];
doesn't work. Is this the problem, or is there a problem with the way I've layed out the array? I'm thinking that the inner NSMutableArray is only alloted so much memory, but I would have thought the array is just an array of references and wouldn't have that issue. I could be wrong - it isn't the first time.
Thanks in advance for wrapping your head around this.
Upvotes: 2
Views: 1059
Reputation: 6991
How are you intializing the array and the values inside it? I think you have an array that is not mutable.
Also an NSMutableArray has a variable size, calling initWithSize is completely unnecessary. The array will resize if it needs to.
Upvotes: 1