版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/yaojinhai06/article/details/80223182
关于C布尔值在swift 里的初始化问题,
这个有两种:
第一种:
var pointer = ObjCBool.init(false);
if file.fileExists(atPath: absPath, isDirectory: &pointer) {
if !pointer.boolValue {
print("abspatch = \(absPath)")
}
}
这种方式: 必须是 var 变量修饰
使用 很简单: 直接.boolValue 就可以;
第二种:
let pointer = UnsafeMutablePointer<ObjCBool>.allocate(capacity: 1);
if file.fileExists(atPath: absPath, isDirectory: &pointer) {
if !pointer.pointee.boolValue {
print("abspatch = \(absPath)")
}
}
这种方式最好用let常量修饰:
使用直接.pointee.boolValue即可:
欢迎纠正.谢谢.....