Ответ 1
Второй параметр имеет тип UnsafeMutablePointer<ObjCBool>
, что означает, что
вы должны передать адрес переменной ObjCBool
. Пример:
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
}
Обновление для Swift 3 и 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
}