views:

72

answers:

1

Visual Studio is one of the best developer IDE of all times, and now was improved with multithreading debugging and much more.

My question is regarding Xcode and the ability to execute code just like we do in Visual Studio.

Let's assume an object in a view and I want to run, let's say:

[pickerView setHidden:YES];

in a breakpoint just to see if in that break point I could actually hide the object.

I can't find any place for this in the XCode Debugger

alt text

Am I missing something or I can't execute code that is not in the files already? like in Visual Studio Watch List or Immediate Window

alt text

+1  A: 

Yes, you can do this using gdb commands. Edit your break-point, then add a "Breakpoint Action" by pressing the plus icon under your breakpoint in the "Breakpoints" window. Select "Debugger Command" from the action type drop-down menu, then type in your command (without the semi-colon). Note that what you can enter here is gdb, not straight Objective-C, so some things won't work as you might expect (such as dot-notation).

You can also type in gdb commands in the Debugger Console while the debugger (gdb) is paused, so you can set a breakpoint, type in a command, then hit continue to see if it did what you were expecting.

Nick Forge
that's not exactly the same as in Visual Studio, where I can use any kind of code and I get intellisense on it as well :-(
balexandre
Does that actually effect your work or productivity? Personally, I find it more helpful (in most situations) to set a breakpoint, then type gdb commands into the Debugger Console to poke around and inspect variables etc. If you want to write code, just write code. gdb isn't that hard to learn, but it's great to know if you're doing Cocoa/CocoaTouch development. Just learning how to print (`print` or `po`) and how to get a backtrace (`bt`) are incredibly helpful.
Nick Forge
I use mostly to watch all variables in a class so I know what can I use. For example, I can ask for `location.coordinate` and see all the sub variables that this class exposes, and their types so I can use the correct approach (where's the value that I'm after, saving time to read and debugging
balexandre
The Debugger Console in Xcode (which is really just a wrapper around gdb) does give you _some_ auto-completion. I think it might be just for variables, not methods though. That said, you should really be discovering "the correct approach" to using a specific class by reading documentation or sample code, not by poking through the list of available methods. :-)
Nick Forge