我NSFileManager.contentsOfDirectoryAtPath用来在目录中获取一组文件名.我想使用新do-try-catch语法来处理错误:
do {
let docsArray = try fileManager.contentsOfDirectoryAtPath(docsPath)
} catch {
// handle errors
print(error) // this is the best I can currently do
}
Run Code Online (Sandbox Code Playgroud)
我可以想象一个错误可能是docsPath不存在的错误,但我不知道如何捕获这个错误.我不知道可能发生的其他错误.
该错误处理的文件有这样一个例子
enum VendingMachineError: ErrorType {
case InvalidSelection
case InsufficientFunds(centsNeeded: Int)
case OutOfStock
}
Run Code Online (Sandbox Code Playgroud)
和
do {
try vend(itemNamed: "Candy Bar")
// Enjoy delicious snack
} catch VendingMachineError.InvalidSelection {
print("Invalid Selection.")
} catch VendingMachineError.OutOfStock {
print("Out of Stock.")
} catch VendingMachineError.InsufficientFunds(let amountNeeded) {
print("Insufficient funds. Please …Run Code Online (Sandbox Code Playgroud) 我注意到有一些软件(例如iExplorer)允许您从Mac访问iPhone设备上的文件.
现在我的问题是:如何通过Objective-c访问iPhone文件?
这仅用于教育目的.
我发现了这个:https://github.com/Chronic-Dev/libirecovery但我不确定我是否走在正确的轨道上.