DocumentActionViewController.swift 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. //
  2. // DocumentActionViewController.swift
  3. // File Provider ExtensionUI
  4. //
  5. // Created by Marino Faggiana on 26/06/18.
  6. // Copyright © 2018 TWS. All rights reserved.
  7. //
  8. import UIKit
  9. import FileProviderUI
  10. class DocumentActionViewController: FPUIActionExtensionViewController {
  11. @IBOutlet weak var identifierLabel: UILabel!
  12. @IBOutlet weak var actionTypeLabel: UILabel!
  13. override func prepare(forAction actionIdentifier: String, itemIdentifiers: [NSFileProviderItemIdentifier]) {
  14. identifierLabel?.text = actionIdentifier
  15. actionTypeLabel?.text = "Custom action"
  16. }
  17. override func prepare(forError error: Error) {
  18. identifierLabel?.text = error.localizedDescription
  19. actionTypeLabel?.text = "Authenticate"
  20. }
  21. @IBAction func doneButtonTapped(_ sender: Any) {
  22. // Perform the action and call the completion block. If an unrecoverable error occurs you must still call the completion block with an error. Use the error code FPUIExtensionErrorCode.failed to signal the failure.
  23. extensionContext.completeRequest()
  24. }
  25. @IBAction func cancelButtonTapped(_ sender: Any) {
  26. extensionContext.cancelRequest(withError: NSError(domain: FPUIErrorDomain, code: Int(FPUIExtensionErrorCode.userCancelled.rawValue), userInfo: nil))
  27. }
  28. }