You don't need to release it. arrayWithArray method creates an autoreleased object, so it is the responsibility of the pool to release the object.
However, if you create the array using alloc/initWithArray then you can do it in two steps so you can keep the pointer to the array to release it.
Quote:
Originally Posted by Aranir
Greetins I'm starting objectiv C and while reading a book I stubled upon the following example:
1 NSMutableArray *displayList = ... // Array of graphic objects
2 GraphicObject *graphicObject;
3
4 NSEnumerator *enumerator =
5 [[NSArray arrayWithArray: displayList] objectEnumerator];
6
7 while ( graphicObject = [enumerator nextObject] )
8 {
9 if ( [graphicObject isBitmap] )
10 {
11 [displayList removeObject: graphicObject];
12 }
13 }
AS I understand to create the NSEnumerator *enumerator, we create a new NSArray with the displayList and create an objectEnumerator from that.
Now my problem is, how do I release the NSArray afterward which was created? as I don't see to have a direct reference to it, but only the object enumerator created from it.
I'm completely new so maybe I miss something how memory is managed in Objective C.
Any advice on this subject would be greatly appreciated.
|