Following my program shows contents of Documents directory and is displayed in a tableView . But the Documents directory contains some directories , some audio , some video , an
For any Swift lovers, coming to this question trying to check if a file is a directory here you go:
///
/// Check if NSURL is a directory
///
internal func fileIsDir(fileURL: NSURL) -> Bool {
var isDir: ObjCBool = false;
fileManager.fileExistsAtPath(fileURL.path!, isDirectory: &isDir)
return Bool(isDir);
}
///
/// Check if a path is a directory
///
internal func fileIsDir(path: String) -> Bool {
var isDir: ObjCBool = false;
fileManager.fileExistsAtPath(path, isDirectory: &isDir)
return Bool(isDir);
}
(Note that I tried doing return isDir as Bool
but it didn't work. But the above Bool initiation seems to work.)