0

I am trying to invoke an external application such as Numbers (.numbers) or Safari (.htm). I have tested this with an internet URL and this works (with slight changes to the code here). I tried to use a htm to invoke Safari local access but no joy. canOpenURL returns true Resp var) however openURL returns false (Resp2). I am not fixed to this code if there is some other way to do this or are there some restrictions with swift and the iOS simulator?

    var txtPath = NSString(string:NSBundle.mainBundle().pathForResource("ReadMe", ofType: "htm")!)
    let targetURL=NSURL(fileURLWithPath: txtPath)
    let application=UIApplication.sharedApplication()
    var Resp=application.canOpenURL(targetURL!)
    var Resp2=application.openURL(targetURL!);
  • 1
    Why are you trying to launch the file URL to your ReadMe.htm file? You need to call `openURL` with a URL representing another app. – rmaddy Jan 12 '15 at 04:14

1 Answers1

0

I am trying to invoke an external application

On iOS, the way to hand a document to another application is to use UIDocumentInteractionController and let the user pick an application. For example, if you start with a Numbers document, the user will be able to pick Numbers from the UIDocumentInteractionController (if it is present on the device).

matt
  • 515,959
  • 87
  • 875
  • 1,141