2

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?

3
  • 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. Commented 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. Commented 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. Commented Nov 25, 2010 at 1:29

3 Answers 3

3

In the gdb console, type

po [myServer root]
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for that, that answers this question and helped me realize that I need help debugging CoreData objects. Thanks!
Stupid question I'm sure, but how do I get this GDB console to show up in Xcode? I'm in version 5.
2

I like to use GDB from the command line. Open a terminal and type

gdb
attach <your process name>

(be sure your program was built with debugging symbols). Then, when your variable name is in scope (e.g. when you break somewhere relevant) type

po variableName

to view its contents.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.