Friday, February 8, 2019

How to add a path when saving data to the documents folder

let filemgr = FileManager.default
let dirPaths = filemgr.urls(for: .documentDirectory, in: .userDomainMask)
let docsURL = dirPaths[0]

let newDir = docsURL.appendingPathComponent("data").path
do {
    try filemgr.createDirectory(atPath: newDir,
                withIntermediateDirectories: true, attributes: nil)
    } catch let error as NSError {
            print("Error: \(error.localizedDescription)")
}