I need to import a bunch of data from CSV files in my app. I have a custom folder 'CSVs' that contains a bunch of '.csv' files. Since these files will change over time, I don't want to use static filenames, but instead just loop through the 'CSVs' folder and read in all .csv files.
I tried this but no files are ever found:
func importCSV() {
let documentsFolderPath = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask, true)[0]
let csvPath = (documentsFolderPath as NSString).stringByAppendingPathComponent("CSVs")
let filemanager = NSFileManager()
let files = filemanager.enumeratorAtPath(csvPath)
while let file = files?.nextObject() {
print("File: \(file)")
}
}