【发布时间】:2016-10-18 17:39:02
【问题描述】:
我正在使用Locksmith 钥匙串包装器。
方法签名是这样的:
public static func saveData(data: [String: AnyObject], forUserAccount userAccount: String, inService service: String = LocksmithDefaultService) throws {...}
我就是这样使用它的:
//Line A—breakpoint
do{
try Locksmith.saveData(["password" : password], forUserAccount: "tech")
}
catch {
// some code}
如果做在我的断点行
po Locksmith.saveData(["password" : password], forUserAccount: "tech")我会得到的
Locksmith.LocksmithError.Duplicate
Locksmith.LocksmithError.Duplicate
我很困惑为什么会两次收到错误消息。假设错误本身是重复的。我更困惑。我不确定这个问题是因为 Locksmith 还是我不了解 try 和 throw 或其他在 Swift 中的工作原理。
PS:我认为如果有人有足够的代表,他们会为Locksmith 创建一个 SO 标签,因为它在某种程度上是一个流行的钥匙串包装器,这将是一个好主意。 1900 人已为它加注星标,我相信还有更多人在使用它。
【问题讨论】:
标签: swift error-handling keychain