The second parameter has the type UnsafeMutablePointer<ObjCBool>
, which means that
you have to pass the address of an ObjCBool
variable. Example:
var isDir : ObjCBool = false
if fileManager.fileExistsAtPath(fullPath, isDirectory:&isDir) {
if isDir {
// file exists and is a directory
} else {
// file exists and is not a directory
}
} else {
// file does not exist
}
Update for Swift 3 and Swift 4:
let fileManager = FileManager.default
var isDir : ObjCBool = false
if fileManager.fileExists(atPath: fullPath, isDirectory:&isDir) {
if isDir.boolValue {
// file exists and is a directory
} else {
// file exists and is not a directory
}
} else {
// file does not exist
}