I am having a bit of trouble creating a dynamically allocated two-dimensional array. If it makes a difference I am coding for ios.
I am a bit new to objective c and the memory allocation in this language is a bit confusing. I did a bit of research and come up with NSMutableArray and this link, 2D arrays using NSMutableArray, but am still confused.
What I am looking to do is create a list of rows and colunms, each row containing a dynamically created number of column objects. The number of rows is also dynamic.
If you think of the layout as a a hash map; graphically, each hash cell will contain a button and a label displayed on the screen.
EDIT:
I have,
NSMutableArray *rows;
NSMutableArray *columns;
- (void)viewDidLoad {
rows = [[NSMutableArray alloc] init];
columns = [[NSMutableArray alloc] init];
//allocate memory?
}
My main question is how to allocate the memory for each entry?
EDIT2:
If anyone needed help with this I got the answer and look more to dictionaries instead of Arrays, they have lots of helpful methods.