iOS根据对象的内存地址找到对应的类

大家在使用自动布局的时候,经常一不小心会出现约束警告,log如下:

[LayoutConstraints] Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. 
    Try this: 
        (1) look at each constraint and try to figure out which you don't expect; 
        (2) find the code that added the unwanted constraint or constraints and fix it. 
(
    "<NSLayoutConstraint:0x283bcbca0 UIView: 0x283badc20.height == 40>",
    "<NSLayoutConstraint:0x283bcbf20 UIView: 0x283badc20.top == UITableViewCellContentView:0x1062e0460.top>",
    "<NSLayoutConstraint:0x283bd74d0 UITableViewCellContentView:0x1062e0460.bottom == UIView:0x1062e0600.bottom>",
    "<NSLayoutConstraint:0x283bb14a0 UITableViewCellContentView:0x1062e0460.height == 1>"
)

我们需要知道哪些对象的约束出现了问题,可以在当前界面出现时,

  1. 点击xcode底部的pause program execution按钮,暂停程序的执行
    image.png

2.输入lldb命令:p (id(0x283badc20))->isa,其中0x283badc20就是对象地址,输出结果为对应的类信息:

(lldb) p (id(0x283badc20))->isa
(Class) $18 = NeighborTest.XLHomePageSectionHeaderView
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容