views:

18

answers:

1

How would I have a button that would add a Section to a UITableView? I know how to do it without adding sections and just having a list but how would you allow the user to add section as well as cells/rows.

+2  A: 

The simplest solution is to maintain a parent NSMutableDictionary dictionary of children NSMutableArray arrays, each child array being its own section of rows.

When you click on the button, it adds an empty NSMutableArray child to the parent dictionary. The key will be the section index or name. The value will be the child array. You then fill the empty child array with your row objects.

Make sure you adjust your delegate methods to reflect the size and content of the parent dictionary and children arrays.

Alex Reynolds
Just what I was looking for, thanks!
Joshua