Question

I have a view controller opening an 'Open-In' dialogue via a bar button item.

Calling code:

UIDocumentInteractionController *docInteraction = [[UIDocumentInteractionController alloc] init];
docInteraction.URL = location;
docInteraction.delegate = self;
if ([docInteraction presentOpenInMenuFromBarButtonItem:self.openInButton animated:YES])
    self.openInController = docInteraction;

Dismissal code:

UIDocumentInteractionController *openIn = self.openInController;
if (openIn) {
    [openIn dismissMenuAnimated:animated];
    self.openInController = nil;
    popupsDismissed = YES;
}

Sometime after the code is dismissed, the app crashes with this exception:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[A2DynamicUIPopoverControllerDelegate popoverController:animationCompleted:]: unrecognized selector sent to instance 0x1f82b4f0'

This is a BlocksKit defined interface, but I'm not using a BlocksKit class in thie particular case. 0x1f82b4f0 is a <A2DynamicDelegate: 0x1f82b4f0; protocol = UIPopoverControllerDelegate> but why BlocksKit is involved here at all is a mystery. Can someone give me some insight on how to fix the exception?

Was it helpful?

Solution

BlocksKit is a bit of a red herring. The dismissal code is deallocating the UIDocumentInteractionController too early here:

    self.openInController = nil;

At the earliest, the deallocation should happen after the -documentInteractionControllerDidDismissOpenInMenu: delegate callback method.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top