Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I look at an object in Xcode's debugger?

I have a simple question about debugging on Xcode and GDB.

I often run into an error:

unrecognized selector sent to instance 0x1081ad0 

which makes the program load into GDB. Is there an easy way to examine what instance is located in that memory from GDB?

like image 759
chibicode Avatar asked Jun 10 '09 22:06

chibicode


People also ask

How do I inspect a variable in Xcode?

When your app pauses at a breakpoint, hover over a variable in your source code to view its current value. If the variable is an image or other type that isn't expressible as text, click the Quick Look button at the upper-right to see a preview of the variable.

How do I see local variables in Xcode?

Right click in the local variables window to see the "Watch Expression" menu command. Type the variable name and the variable will be added.

How do I debug in Xcode step by step?

When you run an application in Xcode, the debugger is automatically started and attached to the process of the application. Click the Run button in the top left or press Command + R. From the moment the application is up and running, we can start inspecting the process and, if necessary, debug it.

How do you evaluate expressions in Xcode?

Evaluate a C/ObjC/C++ expression in the current program context, using user defined variables and variables currently in scope. This command takes 'raw' input (no need to quote stuff). -G <gdb-format> ( --gdb-format <gdb-format> ) Specify a format using a GDB format specifier string.


1 Answers

po 0x1081ad0

po = Print Object. You can even call methods, like

po [myArray objectAtIndex:0]

Note that it only works on objects, so

po 1

will crash your program.

like image 157
Steven Canfield Avatar answered Sep 19 '22 17:09

Steven Canfield