LoginSignup
7
2

More than 5 years have passed since last update.

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

Last updated at Posted at 2019-02-10

例えば、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)
7
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
2