我这样做:检查保留计数
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]);
我dealoc功能得到
retain count1 : 2
retain count2 : 1
1)我能得到这样的消息:
- (void)dealloc{
NSLog(@" retain count2 : %d " , [backgroundImage retainCount]);
[super dealloc];
}
; 2)在最后我得到保留数对于backgroundimage所以它我s ok或应该是0(零) ??
谢谢..
不,你不应该使用它。 为我节省了解释它检查[这一点] [1] [1]:http://stackoverflow.com/questions/4636146/when-to-use-retaincount –