Tim
Tim

Reputation: 4101

UIDocumentInteractionController intermittent crashes

Got a weird iOS issue here...

I have an app that opens PDFs on my iPad. (I've only got to deal with iPads in the environment I'm in)

The weird thing is, sometimes when I try to load a file (the DocumentInteractionController opens, and I choose "Open in iBooks"), my app will crash. If I go back in and select exactly the same options, it works fine a minute later.

If I wait about 10 minutes, I'm back to where I started - the app will crash the first time, but the second and subsequent times it works fine.

This is tough to debug since the interaction with iBooks needs to run on the iPad, I can't run it on the simulator.

Upvotes: 0

Views: 833

Answers (2)

Tim
Tim

Reputation: 4101

It turned out that I was dealloc-ing the documentInteractionController in the documentInteractionControllerDidDismissOptionsMenu method. This was causing the intermittent crashes.

Removing that method (and its call to dealloc) fixed the problem. Instead I release the object in the dealloc method. (Sorry if I'm not using the right terminology here - I'm new to Objective-C/iOS)

Upvotes: 0

dalton_c
dalton_c

Reputation: 7171

I encountered the same issue the other day, and it was because I wasn't strongly referencing the UIDocumentInteractionController. Add a property in your @interface:

@property (nonatomic, strong) UIDocumentInteractionController *documentController;

and assign your controller to this property before you present it.

Upvotes: 3

Related Questions