I am too dumb to know the answer to this one - does anyone know the answer definitively?
NSMutableArray *happyDictionaryEntries;
@property (nonatomic, retain) NSMutableArray *happyDictionaryEntries;
-(void) getStuffFromServer
{
..
self.happyDictionaryEntries = [NSMutableArray
arrayWithContentsOfURL:[NSURL URLWithString:aUrl]];
}
Later we will release the array. I want to actually release all the elements of the array.
So, we would [happyDictionaryEntries release].
(Or I suppose just self.happyDictionaryEntries = nil since it's a property.)
BUT do you also have to [happyDictionaryEntries removeAllObjects] ?
AND/OR do you have to release each item in the array manually?
(Indeed - associated question - does anyone know if removeAllObjects in fact releases each object? It's not really clear what the situation is.) Is there an idiom?
I can manage memory no problem in a typical array that you build up "yourself", but I'm too dumb to understand what the situation is when you have arrayWithContentsOfURL in the mix. If anyone definitively knows the answer, thanks!
"The documentation for NSArray & NSMutableArray state the memory management behavior - Joshua"
Correct. Do you have any documentation for removeAllObjects or for arrayWithContentsOfURL? Can anyone decisively state what removeAllObjects does? Thanks.
"From Apple's Memory Management Programming Guide: [well-known quite form the doco]"-jlehr.
Correct, but what does removeAllObjects do? Does anyone know?
NOTE THAT there seems to be NO documentation on that. The doc on NSMutableDisctionary removeAllObjects for example IS explicit. BUT the doc on NSMutableArray removeAllObjects noticably SAYS NOTHING. It could be like (to make one example) imageNamed which basically doesn't work and does not work as one would perhaps expect.