示例代码:
if let result = Locksmith.loadDataForUserAccount("UserAccount") {
do {
account = Account(
id: result["id"] as! String,
uid: result["uid"] as! String,
username: result["username"] as! String,
name: result["name"] as! String,
image: result["image"] as! String,
token: result["token"] as! String,
client: result["client"] as! String
)
} catch _ {
// Xcode show this warning:
// 'catch' block is unreachable because no errors are thrown in 'do' block
}
}
Run Code Online (Sandbox Code Playgroud)
任何结果的键都可以是零.
有没有办法只是捕获错误,以防它们中的任何一个是零?
swift2 ×1