How do you execute a method and view the return value in the XCode debugger?
How do you execute methods in your program and display the return value. For example, how do I execute the following method
开发者_如何学C[self.view.subviews count]
when the program is stopped at a breakpoint?
Also, how do you view the value of a property w/o hovering over it w/ the cursor?
This is an example of a method call so just view it as such.
You can use either "print object" or "print" statements in gdb. Let's say you have an array with @"one"
and @"two"
as its contents. To print the array do this
gdb> po myArray
To print only the last array object:
gdb> po [myArray lastObject]
To print a simple scalar value use "print" with type information parameter like this:
gdb> p (int)[myArray count]
GDB doesn't know what return type to expect from a method, so you have to tell it by casting the result:
(gdb) print (int)[myArray count]
精彩评论