【问题标题】:Why Xcode return error twice?为什么 Xcode 返回错误两次?
【发布时间】: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 还是我不了解 trythrow 或其他在 Swift 中的工作原理。


PS:我认为如果有人有足够的代表,他们会为Locksmith 创建一个 SO 标签,因为它在某种程度上是一个流行的钥匙串包装器,这将是一个好主意。 1900 人已为它加注星标,我相信还有更多人在使用它。

【问题讨论】:

    标签: swift error-handling keychain


    【解决方案1】:

    我正在运行 Xcode 8 和 Swift3,此时 Xcode 8 似乎有点问题。

    我几乎可以肯定这是一个错误。为什么?

    • 在应用的另一次运行中,它只显示了一次。
    • 我看到了一些其他错误,打印了两次。就像我得到了fatal error: unexpectedly found nil while unwrapping an Optional value 2 次...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-05-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-29
      • 1970-01-01
      • 2023-03-07
      • 1970-01-01
      相关资源
      最近更新 更多