为什么在释放我的物品后我仍然得到retainCount = 1
。
这是我的代码。任何人都可以帮我解决这个问题:
newsDetail *newsdetails = [[newsDetail alloc] initWithNibName:@"newsDetail" bundle:nil];
[newsdetails insertSomeData];
NSLog(@"Object Count in memmory = %d",[newsdetails retainCount]);
[self.view addSubview:newsdetails.view];
NSLog(@"Object Count in memmory = %d",[newsdetails retainCount]);
[newsdetails release];
NSLog(@"Object Count in memmory = %d",[newsdetails retainCount]);
........
2011-09-20 10:26:10.208 memmory[1977:207] Object Count in memmory = 1
2011-09-20 10:26:10.212 memmory[1977:207] Object Count in memmory = 1
2011-09-20 10:26:10.213 memmory[1977:207] Object Count in memmory = 1
答案 0 :(得分:0)
保留分配的对象,因此retain = 1; addSubview将retain count增加1,在release release中将retain减少1。
答案 1 :(得分:-1)
当您在某处将视图添加为子视图时,将保留此视图。