請問這兩個片段完成同樣的事情?假設我有三個IBOutlet中UIButtons我叫buttonOne,buttonTwo接口文件,並buttonThree:自動化的dealloc/viewDidUnload Objective-C的
- (void)dealloc {
for(UIButton* idx in self.view.subviews)
[idx release], idx = nil;
[super dealloc];
}
和
- (void)dealloc {
[buttonOne release], buttonOne = nil;
[buttonTwo release], buttonTwo = nil;
[buttonThree release], buttonThree = nil;
[super dealloc];
}
編輯:
電弧有時好像是一個修復,所有替代內存管理在iOS中,我不喜歡使用它,因爲a)我覺得我是作弊,b)如果我沒有弄錯,它只適用於iOS 5設備。
回覆:編輯B,你就錯了。完整的ARC適用於iOS 4.3,除了弱點之外,您可以在iOS 4.2上獲得大部分ARC功能,您可以使用unsafe_unretained。 – NJones
哦,天哪,我非常非常錯誤! ARC聽起來很夢幻,我要檢查一下。感謝您的推薦! –