Search code examples
iosobjective-clldb

dynamically create image while debugging iOs lldb


I wonder if it's possible to create UIImage and preview it while debugging ios application. I know it's possible if there's already a variable in code which is complied UIImage *img;and while debugging set breakpoint and do something like this in debugger po img = [self createImage]. But when there's no UIImage object in code, is it possible to create one in debugger and preview image ?


Solution

  • Yes.

    Use the temporary variable syntax (dollar-sign prefix) to make sure you can access your variable from LLDB:

    (lldb) e UIImage* $image = [UIImage imageNamed:"blah.png"]
    

    If you want to see the image, you can add $image to Xcode's watch area using "Add Expression..."

    Once you've added it, click the entry for $image and then press the Space key to use Quick Look.