DocumentPickerViewController.swift 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. //
  2. // DocumentPickerViewController.swift
  3. // Picker
  4. //
  5. // Created by Marino Faggiana on 27/12/16.
  6. // Copyright © 2016 TWS. All rights reserved.
  7. //
  8. import UIKit
  9. class DocumentPickerViewController: UIDocumentPickerExtensionViewController {
  10. // MARK: - Properties
  11. var metadata : CCMetadata!
  12. var sectionDataSource = [CCSectionDataSource]()
  13. // MARK: - IBOutlets
  14. @IBOutlet weak var tableView: UITableView!
  15. // MARK: - View Life Cycle
  16. override func viewWillAppear(_ animated: Bool) {
  17. super.viewWillAppear(animated)
  18. /*
  19. NSPredicate(format: "(account == %@) AND (directoryID == %@)", , "33")
  20. let recordsTableMetadata = CCCoreData.getTableMetadata(with: "(account == %@) AND (directoryID == %@)", fieldOrder: <#T##String!#>, ascending: <#T##Bool#>)
  21. */
  22. /*
  23. NSArray *recordsTableMetadata = [CCCoreData getTableMetadataWithPredicate:[NSPredicate predicateWithFormat:@"(account == %@) AND (directoryID == %@)", app.activeAccount, directoryID] fieldOrder:[CCUtility getOrderSettings] ascending:[CCUtility getAscendingSettings]];
  24. _sectionDataSource = [CCSection creataDataSourseSectionTableMetadata:recordsTableMetadata listProgressMetadata:nil groupByField:_directoryGroupBy replaceDateToExifDate:NO activeAccount:app.activeAccount];
  25. */
  26. tableView.reloadData()
  27. }
  28. /*
  29. @IBAction func openDocument(_ sender: AnyObject?) {
  30. let documentURL = self.documentStorageURL!.appendingPathComponent("Untitled.txt")
  31. // TODO: if you do not have a corresponding file provider, you must ensure that the URL returned here is backed by a file
  32. self.dismissGrantingAccess(to: documentURL)
  33. }
  34. override func prepareForPresentation(in mode: UIDocumentPickerMode) {
  35. // TODO: present a view controller appropriate for picker mode here
  36. }
  37. */
  38. static func appGroupContainerURL() -> URL? {
  39. let fileManager = FileManager.default
  40. guard let groupURL = fileManager
  41. .containerURL(forSecurityApplicationGroupIdentifier: capabilitiesGroups) else {
  42. return nil
  43. }
  44. let storagePathUrl = groupURL.appendingPathComponent("File Provider Storage")
  45. let storagePath = storagePathUrl.path
  46. if !fileManager.fileExists(atPath: storagePath) {
  47. do {
  48. try fileManager.createDirectory(atPath: storagePath,
  49. withIntermediateDirectories: false,
  50. attributes: nil)
  51. } catch let error {
  52. print("error creating filepath: \(error)")
  53. return nil
  54. }
  55. }
  56. return storagePathUrl
  57. }
  58. }