【发布时间】:2009-08-25 01:48:04
【问题描述】:
我有两个问题。
1) 其中哪些会释放 ob?
- (void){
ClassOne *ob = [[ClassOne alloc] init]; // should I use autorelease here?
self.O = ob;
[ob release]; // is this correct ??
}
或
-(void)dealloc{
[O release]; // is this correct?
}
2) 有两个类,ClassOne 和 ClassTwo。 ClassTwo 中的一个方法是:
- (void) takeParam:(ClassOne *pt) {
// something going here
}
第三类中还有方法
- (void) runIt {
ClassOne *ob = [[ClassOne alloc] init];
[classTwoOb takeParam:ob];
}
我应该在哪里调用 ClassOne 对象的 release?
【问题讨论】:
标签: iphone memory memory-leaks memory-management