TOP KEK
TOP KEK

Reputation: 2661

Watch NSString length in debugger

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

Upvotes: 6

Views: 575

Answers (2)

aleroot
aleroot

Reputation: 72676

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]

Upvotes: 4

barley
barley

Reputation: 4473

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

Upvotes: 3

Related Questions