This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func downloadAndSaveAudioFile(_ audioFile: String, completion: @escaping (String) -> Void) { | |
//Create directory if not present | |
let paths = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.libraryDirectory, FileManager.SearchPathDomainMask.userDomainMask, true) | |
let documentDirectory = paths.first! as NSString | |
let soundDirPathString = documentDirectory.appendingPathComponent("Sounds") | |
do { | |
try FileManager.default.createDirectory(atPath: soundDirPathString, withIntermediateDirectories: true, attributes:nil) | |
print("directory created at \(soundDirPathString)") |