gpt4 book ai didi

xcode - Swift "guard let"解包失败

转载 作者:行者123 更新时间:2023-11-30 13:29:04 24 4
gpt4 key购买 nike

无法使用 Swift 2.2、Xcode 版本 7.3 (7D175) 解开可选类型

“守卫让”失败 "guard let" failed

但是“guard var”有效 But "guard let" works

请帮忙!这是怎么回事?

编辑1

    let localPresenter = presenter
let localDataSource = dataSource
let configurator: ViewControllerConfigurator = { inputView in
let a = inputView as? ChatTableViewController
guard var chatListController = a else {
throw ApplicationErrors.ModuleConfigureError.WrongViewInput
}
localPresenter.view = chatListController
chatListController.presenter = localPresenter
chatListController.tableView.dataSource = localDataSource
}

编辑2此代码运行良好:

        let localPresenter = presenter
let localDataSource = dataSource
let configurator: ViewControllerConfigurator = { inputView in
let a = inputView as? ChatTableViewController
if let chatListController = a {
localPresenter.view = chatListController
chatListController.presenter = localPresenter
chatListController.tableView.dataSource = localDataSource
} else {
throw ApplicationErrors.ModuleConfigureError.WrongViewInput
}
}

最佳答案

看起来这是 lldb 中的一个错误。如果我在带有“guard”的行上设置断点,则“guard”失败: enter image description here

但是如果我将此断点移过保护 block ,则代码可以正常工作: enter image description here

关于xcode - Swift "guard let"解包失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36792006/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com