I’m doing an alloc/init with my UIPopoverController, then release it in the delegate method. Whenever I perform a “build and analyze”, I get memory warnings with “potential leaks” – am I doing something wrong or is there a way to get rid of those warnings?
Thanks a lot!
- (void) somewhere {
MyViewController *vc = [[MyViewController alloc] init];
UIPopoverController *popover=[[UIPopoverController alloc] initWithContentViewController:vc];
[vc release];
// show the popover
[popover presentPopoverFromRect:[cell frame] inView:self.tableView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
popover.delegate = self;
}
- (void) popoverControllerDidDismissPopover:(UIPopoverController *)popoverController {
[popoverController release];
popoverController = nil;
}
EDIT: show complete somewhere-function
First of all, in the
popoverControllerDidDismissPopover:method you should not release thepopoverControllerinstance, since it will be released by the framework.Second, what’s the meaning of that
somewheremethod? You should post the complete implementation here … I suppose you are showing up the popover view, so you should do something like this:Then, when you no longer need the popover controller, you can release it. You could try with your code, this way:
This way you will always hold the instance of the popover where you need it, and release it when you have finished with it. In your previous implementation that instance was not bound to anything.