-3

I want to dismiss a loader view controller then present an UIDocumentInteractionController. I found an objective-c solution, but I want the Swift 3 one.

This is the objective-c code taken from this answer:

// Does not break
[viewController1 dismissViewControllerAnimated:YES completion:^{
    [self presentViewController:viewController2 animated:YES completion:NULL];
}];

I translated like this in Swift 3:

 self.dismiss(animated: false, completion:{
                                self.docController = UIDocumentInteractionController(url: destinationUrl!)
                                self.docController!.presentOpenInMenu(from: CGRect.zero, in: self.view, animated: true)

})

It works fine, but I want to be sure that the completion:^{ in objective-c means completion:{ in Swift 3.

Community
  • 1
  • 1
Ne AS
  • 1,490
  • 3
  • 26
  • 58

1 Answers1

2

Yes, your assumption is correct. Though you don't need to write completion explicitly in Swift 3.

You can write something like this too.

self.dismiss(animated: false) { 
    self.docController = UIDocumentInteractionController(url: destinationUrl!)
    self.docController!.presentOpenInMenu(from: CGRect.zero, in: self.view, animated: true)
}
Ravi Prakash Verma
  • 1,484
  • 1
  • 15
  • 22