gpt4 book ai didi

swift - 无法在一个特定的类文件中使用 Swift 调试器

转载 作者:搜寻专家 更新时间:2023-10-31 22:20:47 25 4
gpt4 key购买 nike

我可以使用调试器查看我的应用程序中除一个类之外的任何地方的内存值。每次尝试时,无论我尝试 po 什么值,我都会收到相同的错误消息:

(lldb) po searchInstitution.name
error: <EXPR>:2:1: error: cannot convert value of type 'Int' to expected argument type 'Device'
searchInstitution.name
^~~~~~~~~~~~~~~~~
<EXPR>:15:7: error: cannot convert value of type 'Int' to expected argument type 'Device'
if (1==1) {
^

Device 是文件中具有以下定义的结构:

private struct Device: Hashable {
let type: String
let mask: String

var hashValue: Int {
return type.hashValue ^ mask.hashValue
}
}

private func ==(lhs: Device, rhs: Device) -> Bool {
return lhs.type == rhs.type && lhs.mask == rhs.mask
}

但这与我要检查的 SearchInstitution 类实例的字符串属性无关。

有没有人见过这样的事情?关于我可能需要更改以修复它的任何想法?这使得调试 View Controller 非常令人沮丧。

最佳答案

这是一个已知错误。表达式解析器用于包装表达式的代码中与“if (1 == 1)”的冲突已在 github lldb 中修复(通过切换到“do”——在首次编写此代码时不可用。 .), 并且应该将其纳入下一个官方工具版本。

如果您想同时解决它,只需将您的 == 运算符公开而不是私有(private)即可。表达式求值器试图强制本地私有(private)定义优先于可能存在冲突的全局定义,但没有正确执行,因此只能看到私有(private)本地定义。

请注意,更普遍的错误尚未修复,因此如果您在可见的上下文中实际使用私有(private)运算符,则只会使用该运算符定义。

关于swift - 无法在一个特定的类文件中使用 Swift 调试器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38357114/

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