0

I have this code that is called from within a UIAlertController:

func createSomeFile() {

    var output = (some NSData to output to file)


    let fileName = NSTemporaryDirectory().stringByAppendingPathComponent("filename.ext")
    let url: NSURL! = NSURL(fileURLWithPath: fileName)

    var dataToWrite = output.dataUsingEncoding(NSUTF8StringEncoding)
    dataToWrite?.writeToFile(url.absoluteString!, atomically: true)

    documentController = UIDocumentInteractionController(URL: url)
    documentController.UTI = "com.someUTI"
    documentController.delegate = self

    documentController.presentOpenInMenuFromRect(CGRectZero, inView: self, animated: true)
}

The last line throws an error in Xcode: "Cannot invoke 'presentOpenInMenuFromRect' with an argument list of type..."

documentController is declared as a class variable var documentController = UIDocumentInteractionController()

Please help me figure this out.

Mayank Jain
  • 5,663
  • 7
  • 32
  • 65
flightsimmer668
  • 41
  • 1
  • 10

1 Answers1

0

You can't assign self to an argument which should be UIView (unless self is a subclass of UIView, but apparently it is not)

So try this instead:

documentController.presentOpenInMenuFromRect(CGRectZero, inView: self.view, animated: true)
imas145
  • 1,959
  • 1
  • 23
  • 32