У меня есть два контроллера. В первом случае есть прикладом, и когда он щелкнут, второй будет показан методом presentModalViewController
. Однако, когда я возвращаюсь к первому, вызывается dismissModalViewController
, а второй контроллер рассеивается, но память не освобождается. Я использовал инструмент для наблюдения распределения памяти и дуги.ОтключитьModalViewController не освобождает память
Я думал, что могу сделать что-то не так, но я попробовал официальный образец кода, iPhoneCoreDataRecipes и CoreDataBooks, это также произошло. Мне интересно, почему momery не был выпущен?
Ниже приводится код presentModal и dismissModal из официальных рецептов образца:
- (void)add:(id)sender {
RecipeAddViewController *addController = [[RecipeAddViewController alloc] initWithNibName:@"RecipeAddView" bundle:nil];
addController.delegate = self;
Recipe *newRecipe = [NSEntityDescription insertNewObjectForEntityForName:@"Recipe" inManagedObjectContext:self.managedObjectContext];
addController.recipe = newRecipe;
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:addController];
[self presentModalViewController:navigationController animated:YES];
[navigationController release];
[addController release];
}
- (void)recipeAddViewController:(RecipeAddViewController *)recipeAddViewController didAddRecipe:(Recipe *)recipe {
if (recipe) {
// Show the recipe in a new view controller
[self showRecipe:recipe animated:NO];
}
// Dismiss the modal add recipe view controller
[self dismissModalViewControllerAnimated:YES];
}
Я делал подобные вещи, но я использовал дугу вместо так что я не имею линий высвобождения.
Где освободить память secondViewDCotroller? – iPatel
использование [secViewCon_Object release]; secViewCon_Object = nil; – iPatel
Он не может использовать выпуск, потому что использует ARC. Пожалуйста, покажите свой modal view controller. –