I need check files in directory exists and can be open, but my FileManager.default.fileExists(atPath: <#url_from_uidocumentbrowservc#>)
return false. I can't get list of items in selected directory, I can't check my item exists or not.
And one more thing, I want to know how many items are contained in root directory from selected item. For example I choose project file and want to check how many items are contained in project directory then use this files like project dependencies.
Looks to code:
func presentDocument(at documentURL: URL) throws {
let rootDirectoryURL = documentURL.deletingLastPathComponent()
let items = try FileManager.default.contentsOfDirectory(at: rootDirectoryURL,
includingPropertiesForKeys: [],
options: []) // Return error `permission denied`
... other code for init document
}
P.S. URL.startAccessingSecurityScopedResource doesn't work too.