我有一個關於如何最好地管理數組指針以確保沒有內存泄漏發生的問題。我有一個容器類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