Files
insert/insert/DocumentViewController.swift
T
2018-01-04 07:35:57 -05:00

37 lines
1015 B
Swift

//
// DocumentViewController.swift
// insert
//
// Created by Kenneth Reitz on 1/4/18.
// Copyright © 2018 Kenneth Reitz. All rights reserved.
//
import UIKit
class DocumentViewController: UIViewController {
@IBOutlet weak var documentNameLabel: UILabel!
var document: UIDocument?
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// Access the document
document?.open(completionHandler: { (success) in
if success {
// Display the content of the document, e.g.:
self.documentNameLabel.text = self.document?.fileURL.lastPathComponent
} else {
// Make sure to handle the failed import appropriately, e.g., by presenting an error message to the user.
}
})
}
@IBAction func dismissDocumentViewController() {
dismiss(animated: true) {
self.document?.close(completionHandler: nil)
}
}
}