0

May app getting crash when execute below code.

Code: self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:targetURL];

Crash log: Terminating app due to uncaught exception 'NSGenericException', reason: 'UIDocumentInteractionController not available'

is there any solution for this issue or any alternative class?

Yogendra Patel
  • 813
  • 2
  • 8
  • 24

2 Answers2

2

It’s not available in Catalyst, despite what the docs say.

You could explore using an AppKit alternative (QLPreviewPanel), but you’ll have to do some hacking to get it to work from a Catalyst app: https://stackoverflow.com/a/32814132/1601849

Adam
  • 4,405
  • 16
  • 23
0

If you want to leave compatibility with OSX 10.5, you can do this check:

if UIDevice.current.systemName == "Mac OS X" {
   let version = Int (UIDevice.current.systemVersion.prefix (2)) ?? 10
   if version > 10 {
      self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:targetURL];
   } else {
      //do something
   }
} else {
   self.documentInteractionController =[UIDocumentInteractionController interactionControllerWithURL:targetURL];


}