I have a project with ARC.
I have an NSArray whit some object inside.
At certain point I need to change the object in the array.
Whit a NSMutableArray I’ll do :
[array removeAllObjects];
and I’m sure that this method release all object contained in the array.
But with an NSArray I can’t do that! So, my question is: if I set array to nil and then re-initialize it, the old object contained in the array are really released from memory ?
array = nil;
array = [[NSArray alloc] initWithArray:newArray];
Or I need to use NSMutableArray ?
You can just do this:
This will cause
arrayto be released. When thisNSArraygets deallocated, all contained objects will be released, too.