我正在寫一個函數,它只在popOver中顯示一個菜單(由tableView組成)。我有一個對象只有一個分配在同一個函數中的五個分配
這是源代碼:
-(void)pushSearch:(NSString *)option type:(int)optionType
{
searchNav = [[iNavigation alloc] initWithNibName:@"iNavigation" bundle:nil] ;
//This is the UIViewController with the tableView
[searchNav setSearchMode:optionType];
searchNav.view.frame =CGRectMake(0,0,300,600);
NSLog(@"Retain Count: %d",[searchNav retainCount]);
//此時保持計數爲1
if ([pop isPopoverVisible])
{
[pop dismissPopoverAnimated:YES];
[pop release];
}
pop = [[UIPopoverController alloc] initWithContentViewController:searchNav];
NSLog(@"Retain Count: %d",[searchNav retainCount]);
//At this point retain count is 2
[pop presentPopoverFromRect:btnMenu.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
[pop setPopoverContentSize:CGSizeMake(350,600)];
NSLog(@"Retain Count: %d",[searchNav retainCount]);
//At this point retain count is 5!!!
[searchNav release];
}
我正在遇到的問題是,所使用的存儲器加載的tableview是從未發佈。我的應用程序在內存中增長和增長,直到崩潰。
爲什麼只要我爲searchNav創建一個分配,在將其分配給popOver後,reatin計數是5?
請幫忙嗎?
我們是否可以讓`[retaincount]`標籤自動重定向到'[retaincount-is-evil-stopit-stopit-stop]`? – walkytalky 2010-11-27 00:47:34