iOS开发 不能不知的事(1)
_contents = [[NSMutableArrayalloc] init];//[_contentsretainCount] 为 1
self.contents = [[NSMutableArrayalloc] init];//[_contentsretainCount] 为 2
所以self.contents要慎用
if (_contents)
{
[_contents release];
self.contents = nil;
}
知道这一句为什么为异常吗?
它的展开为:
if (_contents)
{
[_contents release];
if(_contents)
{
[_contents release];//关键是这一句出错
_contents = nil;
}
}
浙公网安备 33010602011771号