Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objective - c - NSMutableArray Array of Arrays

I am developing an iphone app and I was wondering the following:

How do I initialise an NSMutableArray of NSMutableArrays to a certain size?

Sorry for the noob question

like image 381
David Avatar asked Dec 09 '22 07:12

David


2 Answers

NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity:5];

for (int i = 0; i < 5; i++) {
   NSMutableArray *innerArray = [[NSMutableArray alloc] initWithCapacity:5];

   [array addObject:innerArray];
}
like image 155
Wayne Hartman Avatar answered Dec 29 '22 12:12

Wayne Hartman


You don't set a maximum size. You just keep addObject:'ing to them

like image 36
Nektarios Avatar answered Dec 29 '22 11:12

Nektarios