草庐IT

contentsOfDirectoryAtPath

全部标签

ios - 如何找到方法可能抛出的错误类型并在 Swift 中捕获它们

这个问题在这里已经有了答案:Howgetthelistoferrorsthrownbyafunction?(3个答案)关闭6年前。我正在使用NSFileManager.contentsOfDirectoryAtPath获取目录中的文件名数组。我想使用新的do-try-catch语法来处理错误:do{letdocsArray=tryfileManager.contentsOfDirectoryAtPath(docsPath)}catch{//handleerrorsprint(error)//thisisthebestIcancurrentlydo}我可以想象一个错误可能是docsPat

ios - 如何找到方法可能抛出的错误类型并在 Swift 中捕获它们

这个问题在这里已经有了答案:Howgetthelistoferrorsthrownbyafunction?(3个答案)关闭6年前。我正在使用NSFileManager.contentsOfDirectoryAtPath获取目录中的文件名数组。我想使用新的do-try-catch语法来处理错误:do{letdocsArray=tryfileManager.contentsOfDirectoryAtPath(docsPath)}catch{//handleerrorsprint(error)//thisisthebestIcancurrentlydo}我可以想象一个错误可能是docsPat