Introduction to UIDocumentInteractionController Swift:
In this post we will learn how to create UIDocumentInteractionController in Swift language. We will create an example app to learn how to use UIDocumentInteractionController in swift. According to Apple docs, UIDocumentInteractionController is a viewcontroller that previews, open, or print files whose file format cannot be handled directly by your app. In short, UIDocumentInteractioncontroller allows us (developers) to open different files using other apps installed on iPhone or iPad device.
You can check objective C version for UIDocumentInteractionController from below link
How to create UIDocumentInteractionController in ObjectiveC
Implementation for UIDocumentInteractionController in swift:
Create a new project and select single view application from app templates and name it “UiDocumentController-Swift”. Change your Language from objective C to swift.
Press Next and then select location for your project where you want to save the project, press create to create your project.
Open ViewController.swift file. Now we will create variable for UIDocumentInteractionController.
Open your Main.storyBoard and drag UIButton to it. It’s time to create an IBAction for our button so that we can open UIDocumentInteractionController on pressing it.
Complete Code for UIDocumentInteractionController:
Where to go from here:
If you are looking for Objective C Version of the UIDocumentInteractionController you can check it from here