NSMutableArray * arrayTest;
-(void) setContent
{
//must I call [array removeAllObjects]; ?
arrayTest = [[NSMutableArray alloc] init]
[arrayTest addObject:@"str"];
...//add many objects
}
I call this function at different code snippet. do I need to removeAllObjects of arrayTest before , then alloc memory for arrayTest every time ? I use ARC .
I don’t want my app memory to increase every time I call this function.
No, what you have is fine. You don’t need to call
removeAllObjectsunder ARC or non-ARC.When the old array is deallocated, it will take care of releasing all of the objects in the old array.