objective c - Correct way to clear/release an array of arrays -


and then my array array ....

When I have an array "x"

/ P>

(A) Array Clearing

(A) Array Clearing

P> [x removeAllObjects];

(B) Issue array

  [x release];  

Or do I need to calculate the array like:

(C) Clean the array

  ( Int i = 0; i & lt; x.count; i ++) [[x object atx: i] release]; [Remove X AllObjects];  

(D) for issuing array

 for  (int i = 0; i  

Thanks in advance

(b) should be sufficient. The array's delacorteer will release all contained objects, with release for each release (many such instances will be released multiple times because they were added multiple times).

Never [[x objectAtIndex: i] release] - You have not placed the returned object, so by releasing this you will keep your count.


Comments