iOS根據(jù)對(duì)象的內(nèi)存地址找到對(duì)應(yīng)的類(lèi)

大家在使用自動(dòng)布局的時(shí)候,經(jīng)常一不小心會(huì)出現(xiàn)約束警告,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>"
)

我們需要知道哪些對(duì)象的約束出現(xiàn)了問(wèn)題,可以在當(dāng)前界面出現(xiàn)時(shí),

  1. 點(diǎn)擊xcode底部的pause program execution按鈕,暫停程序的執(zhí)行
    image.png

2.輸入lldb命令:p (id(0x283badc20))->isa,其中0x283badc20就是對(duì)象地址,輸出結(jié)果為對(duì)應(yīng)的類(lèi)信息:

(lldb) p (id(0x283badc20))->isa
(Class) $18 = NeighborTest.XLHomePageSectionHeaderView
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容