Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Watch NSString length in debugger

I have an NSString variable called myText. How to watch [myText length] in xcode debugger?

like image 842
TOP KEK Avatar asked Jun 10 '12 11:06

TOP KEK


2 Answers

You can use the debugger console to evaluate a property of an object in Xcode, the debugger output view actually functions as an input, too.

Example output

Obviously first you have to Hit a breakpoint ...

It actually works with GDB and LLDB and you have to type in the output console :

print (int)[myText length]
like image 98
aleroot Avatar answered Nov 19 '22 02:11

aleroot


In addition to @aleroot's solution, you can use the variable view of the debugger as well. You can right click on the view and select "Add Expression" and type in whatever you want to monitor. It is a little cumbersome compared to @aleroot's solution, but the merit of this method is that it automatically shows again when you hit the same breakpoint next time.

enter image description here

like image 38
barley Avatar answered Nov 19 '22 03:11

barley