Nat! bio photo

Nat!

Senior Mull.

Twitter RSS

Github

iOS 6.1 WTF: -[UIViewController removeFromParentViewController] overreleases ?!?!!?!

  1. Create a new Xcode iOS Application project "Single View Application". Do not use Storyboards, do not use Automatic Reference Counting, do not use Include Unit Tests. Choose as Device the iPad.
  2. Put the following code in your ViewController.m file
    - (void) viewDidLoad
    {
       UIViewController   *controller;
       
       [super viewDidLoad];
    
       controller = [[UIViewController alloc] initWithNibName:nil 
                                                       bundle:nil];
       [self addChildViewController:controller];
       [controller release];
       [controller removeFromParentViewController];
    }
    
  3. Edit your scheme "Product -> Scheme -> Edit Scheme..." in the Diagnostics Tab to Enable Zombie Objects.
  4. Compile, run and crash.

2013-06-27 10:41:27.086 TestUIViewControllerReleaseBug[1594:c07] *** -[UIViewController _parentViewController]: message sent to deallocated instance 0x7121ff0