Objective-c – NSArray (and other containers) behavior on dealloc


When Objective C containers are dealloc'd, do they release their references to the objects they contain or do I need to do that manually?

Best Solution

Should have read the docs for NSArray closer:

Arrays maintain strong references to their contents—in a managed memory environment, each object receives a retain message before its id is added to the array and a release message when it is removed from the array or when the array is deallocated. If you want a collection with different object ownership semantics, consider using CFArray Reference, NSPointerArray, or NSHashTable instead.