我需要检查从Swift中的函数类型为UnsafeMutablePointer?返回的变量的值。
这是声明:
var isDirectory: UnsafeMutablePointer<ObjCBool>?
当我打印出来时:
print(isDirectory)
我得到:
无
我不太熟悉将Swift与Objective-C混合使用。任何帮助将不胜感激。
这是我的实际完整代码:
let directoryURL: URL = try! FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: false)
let pathOldLocalStorage: String = directoryURL.path + "/OldLocalStorage"
FileManager.default.createFile(atPath: pathOldLocalStorage, contents: nil, attributes: nil)
var isDirectory: UnsafeMutablePointer<ObjCBool>?
let fileExists: Bool = FileManager.default.fileExists(atPath: pathOldLocalStorage, isDirectory: isDirectory)
print("fileExists=", fileExists, "isDirectory=", isDirectory as Any)
这是调试窗口的结果:
fileExists = true isDirectory = nil
答案 0 :(得分:0)
您需要这样称呼它:
new PDO("sqlsrv:Server=localhost;Database=DB", "User", "Password");