1

When I enter a breakpoint in Xcode I can see the Variables View in the Debugger area.

enter image description here

Since the UInt32 type that I am working with represents Unicode values, I would like to change the display value from decimal to hexadecimal or some Unicode type. I can do that by right-clicking and selecting View Value As.

enter image description here

Which gives

enter image description here

But I find myself having to do this over and over.

Is there any way to change the default display type?

I thought I had seen this before, but it turns out that it was a similar question for Android Studio. I looked in preferences but couldn't see anything there either.

Community
  • 1
  • 1
Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
  • Unicode characters are represented in Objective-C using `unichar` (a 16-bit type). Why are you using `uint32_t`? – trojanfoe Feb 06 '16 at 10:45
  • 1
    I'm coding in Swift rather than Obj-C. For a number of reasons (see [this question](http://stackoverflow.com/q/31272561) and its edit history and answer), I decided to work with Unicode scalars instead of `unichar` or Swift `Character`. But even if it were `unichar` or something else, I am still looking for a way to change the default display type in the debugger area. – Suragch Feb 06 '16 at 11:02

1 Answers1

2

The "type format add" command will do what you want. Do:

(lldb) help type format add

for more details. It will change the default format for any variable of the given type. You can either enter these at the lldb prompt or in your ~/.lldbinit. One caveat, the Xcode locals view doesn't update itself when the formatters change, so you will have to "step" to get the format change to register.

Another trick you can use if you have a mix of UInt32's that you use for this purpose and others that you use as UInt32's (and thus would want to see with the default format), you can create a typealias to UInt32, and use that when you intend the Unicode usage. Then you can put the formatter on the typealias rather than on UInt32. That way you will get the formatting where you want it and not in other uses.

Another little trick that you can use is to add your special type formats to a category when you make them (using the -w option.) That allows you to use the "type category enable/disable" to turn your special formatting on and off without having to remember the "type format add" command. If you do this, note that categories are created "disabled", so you will have to enable the category before you will see its effects.

Jim Ingham
  • 25,260
  • 2
  • 55
  • 63