关于 func unc createDirectoryAtURL 的警告('()' 类型的值)
a warning about func unc createDirectoryAtURL(value of the type '()' )
我正在学习 iOS 开发,今天我尝试编写一些关于 FileManger 的代码enter image description here,但是这个方法 return 是一个类型 '()',我该如何解决是吗?
警告代码如下:
问题是您对 createDirectoryAtURL
的调用没有明确的 return 值。在 Swift 中,这意味着它 return 是一个 Void
,由空元组 ()
表示。这就是您的电话应该看起来的样子。
let temp = NSTemporaryDirectory()
let newDiretoryURL = NSURL.fileURLWithPath(temp + "/MyNewDirectory")
try fileManager.createDirectoryAtURL(newDiretoryURL, withIntermediateDirectories: false, attributes: nil)
print("Success")
}
} catch {
// handle errors here
}
我正在学习 iOS 开发,今天我尝试编写一些关于 FileManger 的代码enter image description here,但是这个方法 return 是一个类型 '()',我该如何解决是吗?
警告代码如下:
问题是您对 createDirectoryAtURL
的调用没有明确的 return 值。在 Swift 中,这意味着它 return 是一个 Void
,由空元组 ()
表示。这就是您的电话应该看起来的样子。
let temp = NSTemporaryDirectory()
let newDiretoryURL = NSURL.fileURLWithPath(temp + "/MyNewDirectory")
try fileManager.createDirectoryAtURL(newDiretoryURL, withIntermediateDirectories: false, attributes: nil)
print("Success")
}
} catch {
// handle errors here
}