Ad

Creating Hidden/private Directories FileManager Swift

- 1 answer

My app needs to have a hidden/private(if possible) folder for storing audio files that the app generates itself. This audio files are used to build Database where only the App can populate and delete if needed.

The only activity that the user is able to do is exporting some of this file in a folder called "exported" into either the share folder or the iCloud.

The question is, how do I create this hidden/private folder where a User has no permissions?

Ad

Answer

lazy var documentsUrl:URL = { return fileManager.urls(for: .documentDirectory, in: .userDomainMask).first! }()
lazy var appInternalMusic:URL = { documentsUrl.appendingPathComponent(".InternalFolder") }()  
try! fileManager.createDirectory(at: appInternalMusic, withIntermediateDirectories: true, attributes: nil)
Ad
source: stackoverflow.com
Ad