In a sandboxed document based project for macOS, I would like to programmatically save on disk a document. The location have to be not accessible to the users: I would have thought of "CurrentFiles" or such, into Application Support folder. How can I create the folder?
This is the code I 'M using to date for testing:
let directoryURL = FileManager.default.urls(for: .desktopDirectory, in: .userDomainMask).first // then use .applicationSupportDirectory
let docURL = URL(string:"MyFile.test", relativeTo:directoryURL)
if (try? document.write(to: docURL!, ofType: "com.myCompany.test")) != nil {
} else {
print("An error occured")
}