Par*_*oja 2 nsfilemanager ios swift swift2
Swift 1.2代码:
var error:NSError? = nil
if (fileManager.removeItemAtPath(exportPath as String, error: &error))
{
//Error - handle if requried
}
Run Code Online (Sandbox Code Playgroud)
当我使用try和catch块时,我无法将此代码编译为Swift 2.0.
Swift 2.0代码
do {
check = try fileManager.removeItemAtPath(exportPath as String)
if(//some condition)
{
// whatever
}
}
catch {
check = nil
}
Run Code Online (Sandbox Code Playgroud)
Kut*_*yel 11
这是要走的路,你不再需要这个error参数了!
do {
try fileManager.removeItemAtPath(exportPath as String)
} catch {
// Error - handle if required
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2836 次 |
| 最近记录: |