【发布时间】:2011-07-12 14:43:50
【问题描述】:
我对 removeFromSuperview 的内存管理感到困惑。
这是我的代码:
MySubView *tMySubView = [[MySubView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
tMySubView.center = self.view.center;
tMySubView.tag = 1111;
[self.view addSubview:tMySubView];
[tMySubView release];
“self”是 UIViewController。
当“self”调用dealloc但MySubView没有调用dealloc时。
我知道 addSubView retainCount +1。
所以我尝试在“self” dealloc 中添加 [tMySubView removeFromSuperview]
并且调用了 MySubView dealloc...
我应该添加 [subView removeFromSuperview]; superView什么时候dealloc?
或者superView removeFromSuperview ,会自动调用subView的removeFromSuperview...?
我想不通。 :(
谢谢!
【问题讨论】:
标签: iphone objective-c memory-management dealloc