Viewing complex objects in debugger

452 Views Asked by At

Is it possible to construct custom views for complex objects?

Specifically I want to view the inner workings of a CGPath.

I've found the "view variable as" option with right clicking the variable in the debug view, and I've seen ways to view (eg) strings &tc with it, but I haven't found anything that helps me in this case.

1

There are 1 best solutions below

9
jrturton On

po path in the debugger will print out all of the path's elements. UIBezierPath has quick look support in the debugger, where you can hit space and view a drawing of it, but you have a CGPath. It seems that quick look support is not enabled for CF classes like CGPath.

But you're not stuck. If you right-click the variables list in the debugger (as shown here), and choose add expression, you can create a local UIBezierPath by typing this in the expression field:

UIBezierPath(cgPath: path)

or, if your debugger is in an Objective-C context:

[UIBezierPath bezierPathWithCGPath: path]

Your expression then shows up in the list, and you can press the space bar to see a visual representation.

This example shows how I have it set up in an Objective-C project:

enter image description here

Quick-looking the path shows this:

enter image description here

If po path isn't showing you any components (moveto, curveto etc) in the debugger, then I think you have an empty path, and your problem lies elsewhere. If otherPath is nil, then I get an invalid expression in the debugger when creating the bezier path.