Objective-c – With an NSArray of object references, do I explicitly release all objects in the array or just the array itself

iphonememory-managementobjective c

My class has an NSArray that is filled with objects. In my dealloc method, can I simply call release on my NSArray, or do I need to iterate the array and release all objects first?

Best Answer

You can call release directly on the NSArray. The implementation of NSArray will take care of sending release to all the objects stored in the array.