1
Help us understand the problem. What are the problem?

More than 3 years have passed since last update.

posted at

updated at

Organization

LLDBでアドレスからオブジェクトの内容を確認する

例えば、XcodeのDebugging View Hierarchiesを使ってデバッグ中に取得したアドレスから、オブジェクトのより詳細な内容を確認したいときなどがあるかと思います。
そこで、SwiftのunsafeBitCast(_:to:)を使えば簡単にアドレスからオブジェクトの内容を確認することができます。

LLDBでは以下のようなコマンドで確認できます。

(lldb) expr -l Swift -- import UIKit
(lldb) expr -l Swift -- let $label = unsafeBitCast(0x7fac81778d00, to: UILabel.self)
(lldb) expr -l Swift -- print($label.font)
Optional(<UICTFont: 0x7fac81779410> font-family: ".SFUIDisplay-Bold"; font-weight: bold; font-style: normal; font-size: 22.00pt)
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Sign upLogin
1
Help us understand the problem. What are the problem?