@interface Rectangle
@property (retain) UIView *view;
@end
@implementation Rectangle
CGRect frame = CGMakeRect();
self.view = [[UIView alloc] initWithFrame:frame]
Student *student=[[Student alloc]init];
[student release]; // not using this but using dealloc on it see below
- (void)dealloc {_view release; [super dealloc]; [学生dealloc]; } @end
我的问题是: 这里我们为什么要解除超对象的内存????如果我们释放释放它的学生的记忆会发生什么?我必须手动释放声明为保留的属性吗?
问自己为什么不使用ARC(自动参考计数)。 – rmaddy 2014-09-23 18:33:23
并找到一个现代化的教程。 '@ synthesize'行不需要。 – rmaddy 2014-09-23 18:34:10
半无关,但如果你没有使用ARC,并且像你在那里重写-dealloc那样,你必须在它的末尾调用[super dealloc]。否则,你会泄漏物体。 – 2014-09-23 18:40:34