[英]Why am I still getting retainCount=1, after releasing my objects
釋放對象后,為什么我仍然保持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
分配的對象被保留,因此retain = 1; addSubview將保留計數增加1,在發布調用中將保留減少1。
當您在某處將視圖添加為子視圖時,將保留該視圖。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.