我有一个关于如何最好地管理数组指针以确保没有内存泄漏发生的问题。我有一个容器类A和一个合成类B.两者都有一个数组属性,并且都对数组做了它们自己的事情。但容器是暴露给公共API的唯一类。所以我设置了classA.someProperty,并在内部像下面那样设置classB.someProperty。我需要做什么样的清理工作? ARC会自动为我处理这个问题吗?IOS - 内存管理指针
class A
@property(nonatomic,strong) NSMutableArray* someProperty;
@property(nonatomic,strong) ClassB* classB;
Class B
@property(nonatomic,strong) NSMutableArray someProperty;
并在A类中执行;
classB.someProperty = [self.someProperty mutableCopy]
//do some other work with self.someProperty
and in the implementation in Class B;
//do some work with self.someProperty [Includes modifications to the array]
如果你在' - dealloc'中设置'strong'属性为'nil',那应该没问题。这是***的参考点***。*** – 2013-06-18 18:11:37
你确定将属性设置为无dealloc - http://stackoverflow.com/questions/7906804/do-i-set-properties-to-nil-in -dealloc-when-arc- – user2453876
@userXXX是的。看过那个咆哮。 BS,最好。 – 2013-06-18 18:14:46