3

I understand that when you reach a breakpoint while debugging in Xcode you can hover the mouse pointer over objects and see their properties. But with most objects you only get a few of the properties. The rest are hidden. Trying this with a CLLocation object is next to useless.

Is there another way to peer inside this object while debugging? Do I just have to resort to using NSLog to get what I want?

Christian Schlensker
  • 21,708
  • 19
  • 73
  • 121
  • Check out the answers to this question also: http://stackoverflow.com/questions/3249108/intelligent-obj-c-variable-contents-while-debugging-in-xcode – Ben Zotto Aug 22 '11 at 17:29
  • another thread that arrives at @kevboh's answer: http://stackoverflow.com/questions/112796/how-to-view-contents-of-nsdictionary-variable-in-xcode-debugger – ericsoco Feb 03 '13 at 06:56

3 Answers3

2

use the command: po VARNAME This will print out the value for you

box86rowh
  • 3,415
  • 2
  • 26
  • 37
  • I try this with myLocation.horrizontalAccuracy and I get "member not found". Does it only work for variables, and not for methods on those variables? – Christian Schlensker Aug 22 '11 at 20:36
1

As box pointed out, the gdb po command will print out whatever a varname points to. Xcode's debugger panel (the bottom pane in Xcode4) will also list out all objects in the current scope and allow you to view their ivars by clicking the disclosure buttons next to the objects. For Apple classes, though, this doesn't work so great, so I'd rely more on po, NSLog, and Apple's docs.

kevboh
  • 5,207
  • 5
  • 38
  • 54
0

Create a -(NSString *)description method for whatever object you're trying to view.

At a breakpoint, right click on the variable in the local/global variable list (next to Console output) and click Print Description of "...". This will print out whatever details you want.

AWF4vk
  • 5,810
  • 3
  • 37
  • 70