LLDB (Swift): Casting Raw Address into Usable Type

前端 未结 11 819
天涯浪人
天涯浪人 2020-11-27 09:30

Is there an LLDB command that can cast a raw address into a usable Swift class?

For example:

(lldb) po 0x7df67c50 as MKPinAnnotationView
11条回答
  •  醉话见心
    2020-11-27 10:01

    Under Xcode 8.2.1 and Swift 3, the lldb command po or p won't work with the typed variable. You will need to use the swift command print to examine the properties of the typed object instance. (Thanks to cbowns's answer!) E.g.:

    expr -l Swift -- import UIKit
    expr -l Swift -- let $pin = unsafeBitCast(0x7df67c50, to: MKPinAnnotationView.self)
    expr -l Swift -- print($pin.alpha)
    

提交回复
热议问题