在Swift中,fileExistsAtPath(_ path:String,isDirectory isDirectory:UnsafeMutablePointer< ObjCBool​​>) - > Bool仅接受单个参数 [英] In Swift fileExistsAtPath(_ path: String, isDirectory isDirectory: UnsafeMutablePointer<ObjCBool>) -> Bool accepts single parameter only

查看:394
本文介绍了在Swift中,fileExistsAtPath(_ path:String,isDirectory isDirectory:UnsafeMutablePointer< ObjCBool​​>) - > Bool仅接受单个参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下示例中的方法fileExistsAtPath()仅接受单个参数。

The method fileExistsAtPath() in the example below accept single argument only.

if fm.fileExistsAtPath(result, isDirectory:&isDir) {

确切的错误信息是:调用中的额外参数'isDirectory'。

The exact error message is: "Extra argument 'isDirectory' in call".

知道什么是错的吗?

推荐答案

有些人可能会发现这个小整洁。这是Swift 3。

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.
}

这篇关于在Swift中,fileExistsAtPath(_ path:String,isDirectory isDirectory:UnsafeMutablePointer< ObjCBool​​>) - > Bool仅接受单个参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆