In Swift fileExistsAtPath(_ path: String, isDirectory isDirectory: UnsafeMutablePointer<ObjCBool>) -> Bool accepts single parameter only In Swift fileExistsAtPath(_ path: String, isDirectory isDirectory: UnsafeMutablePointer<ObjCBool>) -> Bool accepts single parameter only ios ios

In Swift fileExistsAtPath(_ path: String, isDirectory isDirectory: UnsafeMutablePointer<ObjCBool>) -> Bool accepts single parameter only


The problem is that isDirectory is UnsafeMutablePointer<ObjCBool> and not UnsafeMutablePointer<Bool> you provide. You can use the following code:

var isDir = ObjCBool(false)if NSFileManager.defaultManager().fileExistsAtPath("", isDirectory: &isDir) {}if isDir.boolValue {}


Some might find this a little neater. This is Swift 3.

var directory: ObjCBool = ObjCBool(false)var exists: Bool = FileManager.default.fileExists(atPath: "…", isDirectory: &directory)if exists && directory.boolValue {    // Exists. Directory.} else if exists {    // Exists.}


It is

func isDirectory(path: String) -> Bool {  var isDirectory: ObjCBool = false  NSFileManager().fileExistsAtPath(path, isDirectory: &isDirectory)  return Bool(isDirectory)}


matomo