Search code examples
objective-ciosuidocumentinteraction

How can I open a file in another app using UIDocumentInteractionController?


I'm having trouble trying to open a file.

I download a document file somewhere, and I have a viewer to view the file on my iPhone. I want my app to open the file to the viewer.

Here's what I'm trying to do in -(IBAction)buttonPressed:

dc = [UIDocumentInteractionController interactionControllerWithURL:url];
if([dc presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES])
{
   NSLog(@"menu is presented");
}

When I run the program and click trigger buttonPressed, the NSLog message is printed, and an action sheet appears with two options. One is evernote, the other one is viewer.

However, when I click either option in the action sheet popup, nothing happens.

What am I missing? Do I need to implement a delegate method?

Please help. Thanks!


Solution

  • i've got the answer.

    i must retain dc..

    fool mistake :(