关于内存管理的几个基本要点!!(例子)

首先:如果alloc一个对象就必须要释放代码
比如:
Test *t = [[Test alloc] init];
Test1.t = t;
[t release];

或者
Test1.t = [[[Test alloc] init] autorelease];


在dealloc释放中,不要使用self去得到对象
请用下划线+属性名去得到对象
- (void)dealloc{
    [_t release];
    [super release];
}



猜你喜欢

转载自rayln.iteye.com/blog/1953285