Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LLDB (Swift): Casting Raw Address into Usable Type

Tags:

ios

swift

lldb

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

For example:

(lldb) po 0x7df67c50 as MKPinAnnotationView 

I know that this address points to a MKPinAnnotationView, but it is not in a frame that I can select. But, I want to cast the raw address into a MKPinAnnotationView so that I can examine its properties. Is this possible?

like image 602
jarrodparkes Avatar asked Apr 04 '15 00:04

jarrodparkes


1 Answers

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) 
like image 135
Xi Chen Avatar answered Sep 21 '22 22:09

Xi Chen