I enabled Document Types to import or copy files from other apps to my application. I have some questions :
1- Where should create the method of moving files form Inbox to Document directory ? is this the right place ?
func applicationWillEnterForeground(_ application: UIApplication)
2- On first view controller I am getting files from Document directory :
func getFileListByDate() -> [String]? {
let directory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
if let urlArray = try? FileManager.default.contentsOfDirectory(at: directory,
includingPropertiesForKeys: [.contentModificationDateKey],
options:.skipsHiddenFiles) {
return urlArray.map { url in
(url.lastPathComponent, (try? url.resourceValues(forKeys: [.contentModificationDateKey]))?.contentModificationDate ?? Date.distantPast)
}
.sorted(by: { $0.1 > $1.1 }) // sort descending modification dates
.map { $0.0 } // extract file names
} else {
return nil
}
}
But when a file imports to my app there is Inbox
folder(item) in my table view , how can I automatically move files from Inbox
to Document
directory and remove Inbox folder ?