I come from a .Net world so I'm used to just hovering over a variable while debugging and seeing what its value is.
In Objective-C I am incredibly confused on how to do that.
If I hover over it, I get a small popup with lots of information...that doesn't help me at all.
For example, I have an object called "myServer" and it is an instance of a "Server" that I have created through CoreData. One of its properties is "root" which is a simple NSString.
I cannot for the LIFE of me figure out how to view what the value of [myServer root] is.
Can some please give me some advice on this?
-
Hovering over values in XCode, and navigating the disclosure triangles in those popups, works so well that I move mountains to develop linux-targeted programs in OS X to enjoy that behaviour.Jarret Hardie– Jarret Hardie2010-11-25 01:22:29 +00:00Commented Nov 25, 2010 at 1:22
-
When I hover over it I get a popup that says it's of type "Server" and when you expand that triangle it says it is of type "ManagedObject" and from there it's just a bunch of useless information that at no point shows the properties I have defined.James P. Wright– James P. Wright2010-11-25 01:28:49 +00:00Commented Nov 25, 2010 at 1:28
-
Also, here is what I see when I hover over an NSString called "username". jamespwright.com/images/public/screengrabs/… There is NO data in there that makes any sense to what I am looking for.James P. Wright– James P. Wright2010-11-25 01:29:27 +00:00Commented Nov 25, 2010 at 1:29
3 Answers
In the gdb console, type
po [myServer root]
2 Comments
Another nice way to deal with this is to log directly from a breakpoint.
To do this, create a breakpoint after the value you want to see has been set, then edit it. Add a breakpoint action of 'log', and put the expression you want logged within a pair of @ symbols. Check the box to the right, ensuring that the breakpoint doesn't actually cause a stop. The value will be output to the debugger console on doing a run & debug.
Doing it this way you (a) don't clutter your source, (b) can dis/enable the breakpoint at will according to your immediate needs, and (c) don't need to stop execution.
This and other very handy xcode tips can be culled from Joar Wingfors' 'Debugging with Xcode' talk.