首页 > 解决方案 > 为什么我收到错误“EXC_BAD_ACCESS”

问题描述

我正在尝试使用网站的建议来调试我的自动布局,以突出显示导致约束问题的视图。但是,当我尝试使用命令更改可疑视图的颜色时

expr ((UIView *)0x7f9ea3d43410).backgroundColor = [UIColor redColor]

我得到错误

error: Execution was interrupted, reason: EXC_BAD_ACCESS (code=1, address=0xcd4200020).
The process has been returned to the state before expression evaluation.

我也得到了错误:

error: Execution was interrupted, reason: Attempted to dereference an invalid ObjC Object or send it an unrecognized selector.
The process has been returned to the state before expression evaluation.

我不确定为什么会收到此错误,因为我已确保将示例十六进制代码替换为我自己的,此错误甚至意味着什么?

我正在快速编码,我引用的网站使用objective-c,这可能是我的问题。快速代码会做同样的事情吗?我努力了:

expr ((UIView *)0x7f9ea3d43410).backgroundColor = UIColor.redColor

标签: swiftxcodeautolayout

解决方案


我认为简短的回答是“该链接来自 2015 年,推荐的技术使用不再支持的隐藏内部符号。”

具体来说,符号是_autoLayoutTrace。那是一个私人符号,显然已被删除。


推荐阅读