iOS SDK UIPopoverController with ARC pre-emptively deallocs.

Originator:adam.weeks
Number:rdar://13862664 Date Originated:5/10/2013
Status:Open Resolved:
Product:iOS SDK Product Version:iOS 6.1
Classification:Crash Reproducible:Always
 
Summary:
When calling a UIPopoverController via a local variable in an ARC project, the controller has dealloc called on it while it is still active.

Steps to Reproduce:
Call a popover controller with the following code:

    UIPopoverController *popover_ = [[UIPopoverController alloc] initWithContentViewController:controller];
    [popover_ presentPopoverFromRect:scale_.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
    popover_.delegate = self;


Expected Results:
The view presented via the popover controller does not cause the application to crash.

Actual Results:
The application crashes when dealloc is called on the popover controller.

Regression:
If the popover is assigned to an instance variable, the dealloc method is not called. Unfortunately, if simply a quick popover is needed, one cannot be made without the instance variable. Also, if a project is not in ARC, the code works as well without the dealloc crash.

Notes:
Nothing additional.

Comments

If you call the same code in MRC

... this will simply be a leak. It's an unfortunate design decision on Apple's part (even though they have clearly thought about it and also a private property to retain self while being visible, see https://twitter.com/steipete/status/333629160708788225).

use a property like the rest of us :)


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!