mirror of
https://github.com/kennethreitz-archive/insert.git
synced 2026-06-05 23:20:19 +00:00
37 lines
1015 B
Swift
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)
|
|
}
|
|
}
|
|
}
|