objective-c - NSArray(和其他容器)在 dealloc 上的行为

标签 objective-c iphone

当 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/

相关文章:

ios - 访问容器 View 中的另一个 View Controller 的 IBOutlets

iphone - 如何检测 iPhone OS 设备是否具有接近传感器?

iphone - 在 EKEventStore 中检索具有特定标题的 EKEvent

iPhone数据传输问题

ios - Flurry 分析 "Table Failed to Load"错误

ios - 当我尝试导入它时,为什么它说找不到我的类(class),而它显然在侧边栏中?

objective-c - @private 是如何实现的?

objective-c - For循环不删除 View ?

iphone - NSURLConnection 因 URL 无效而挂起

iphone - iPhone 上的 3G 网络电话,SDK 有何变化?