I am trying to figure out how the following method does not cause a memory leak. A UIPopoverController
is allocated, yet, if I include an autorelease
or release
call, the application crashes, with the message '-[UIPopoverController dealloc] reached while popover is still visible.'
.
-(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control {
[mapView deselectAnnotation:view.annotation animated:TRUE];
if ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ) {
UIViewController *con = [[UIViewController alloc] init];
UIPopoverController *poc = [[UIPopoverController alloc] initWithContentViewController:con];
[con release];
poc.popoverContentSize = CGSizeMake( 320, 320 );
[poc presentPopoverFromRect:view.bounds inView:view permittedArrowDirections:UIPopoverArrowDirectionAny animated:TRUE];
}
else {
; // TODO (miked): display stuff another way
}
}
This seems to go against basic memory management practices.
p.s. I have not enabled ARC.