I am new to Objective-C and still don't completely grasp the memory management. I have an NSMutableArray of pointers...
NSMutableArray *itemArray;
throughout my program, I add items to it.
//start loop
MyItem *x = [[MyItem alloc] init];
[itemArray addObject:x];
//end loop
There comes a point when I want to toss all items in the array and re-populate it. Do I just loop through the whole array and send a release message to every object in the array as my intuition tells me, and then removeAllObjects, or does removeAllObjects take care of decrementing all the reference counts? Is the following correct?
//start loop
[[itemArray objectAtIndex:i] release];
//end loop
[itemArray removeAllObjects];