【发布时间】:2011-08-20 09:50:41
【问题描述】:
我正在这样做:
UIImageView *backgroundImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"mainback.jpg"]];
[self.view addSubview:backgroundImage];
NSLog(@" retain count1 : %d " , [backgroundImage retainCount]);
[self.view sendSubviewToBack:backgroundImage];
[backgroundImage release];
NSLog(@" retain count2 : %d " , [backgroundImage retainCount]);
我明白了
retain count1 : 2
retain count2 : 1
1) 在dealoc 函数中我可以得到如下消息:
- (void)dealloc{
NSLog(@" retain count2 : %d " , [backgroundImage retainCount]);
[super dealloc];
}
并且 2) 最后我得到了 backgroundimage 的保留计数 1 所以没关系,或者应该是 0(zero)?
谢谢..
【问题讨论】:
-
不,你不应该使用它。节省我解释它检查[这个][1] [1]:stackoverflow.com/questions/4636146/when-to-use-retaincount
标签: iphone xcode4 dealloc retaincount