I need to keep track of rows in sections in my UITableView. For this I want to create an array in which I put an amount of rows in each section. This array should be of a certain size – so I suppose it would be better to use NSArray instead of NSMutableArray.
My question is – how can I initialize it with a certain number of objects of type NSInteger initially set to 0? And how can I alter that array – in my particular case to increase value of each item when I need it?
For instance:
while (objects) { myArray.(object string's first letter transformed to int)++; }
If the array is a specific size and all regular integers (NSInteger in your example), why not just use a simple integer pointer? For example:
If your requirements call for a simple, fixed-capacity array all consisting of the same, primitive type, I think that the simple solutions are best. If the length of the array will never change (i.e., you know the length at compile time), you can use an NSInteger array as your instance variable instead of a pointer, that way you don’t have to deal with allocating the memory or freeing it. Also, in that case, you will get a zero-ed out array automatically.