objective c - NSArray : release its objects, but keep a pointer to it -


I declare an NSArray in my code, then I am creating an array from another array. I process my NSArray and when I am finished, I would like to release objects, but I am reusing this pointer again in the NSERRE for the same process (create array from another array I am issuing the process, then). I need to keep an indicator what should I do?

Here's almost what I want to do, buildArray is creating an autorespread NSArray and returning:

  NSArray * myArray; For (int i = 0, i & lt; 10, i ++) {myArray = [NSArray arrayWithArray: [auto createdArray]]; // here myArray process ... myArray = zero; // my guess is)  

I should put an indicator in my NSER for later use in the loop, but what happens with objects created with [self generated array] Used to be?

Or perhaps the best solution is to remove all objects in the array?

Thank you!

You can not reuse an NSArray because it is irreversible. You can use an NSMutableArray (which supports -removeAllObjects )

If you need, keep the indicator, but it is not needed continuously within the loops, then you just use

  loop {NSArray * myArray = [Auto createdArere]; ... // myArray = Zero; // Optional}  

Comments