当 Objective C 容器被释放时,它们是否释放对其所包含的对象的引用,还是我需要手动执行此操作?
最佳答案
应该仔细阅读 NSArray 的文档:
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.
关于objective-c - NSArray(和其他容器)在 dealloc 上的行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/693702/