views:

122

answers:

2

I know that might sound like a stupid question since it's a trivial feature in most modern IDEs, but I'm diving into iOS development and am getting familiar with the platform and SDK and I can't figure this out. I have a ton of experience with MS Visual Studio and I see that Xcode works very much the same, tho it's still lacking quite a bit of functionality in comparison, but still a very good IDE. When it comes to debugging, Xcode works very similar to Visual Studio in that you can hover your mouse over a variable and it will display its current value. When it comes to object variables, however, it almost always give just the address along with the expand arrow, which expands to "NSObject", which expands to "isa", which expands to all the attributes that don't tell me anything. I'm used to the IDE, like Visual Studio, being smart enough to do some introspection and display for me the actual object and all it's immediate properties and values. I'm assuming Xcode is smart enough to do this and I'm just not using it correctly.

If I set a breakpoint on a line of code that involves an object instance (lets say NSDateComponents instance), how can I view the values of its properties (i.e. year, week, day, hour, etc.)?

Thanks in advance for your help!

Edit: Here's a screenshot of the info I get with every object I inspect... alt text

A: 

Hover over a variable and a line will pop up about it. Move your mouse right very slightly, and hover over the triangle arrow that's at the left side of the popup, that arrow will turn downward, and another popup will open showing all the named properties of that object.

You can also get it to print its "description" value. Move your pointer slightly right until it's over the two little "up/down" arrows. Then left (well, "main") click. A pop-up will show up and one option will be "Print description". If you click on that, it'll put the output of its -description method to the console.

Dan Ray
thanks dan, but like i said, when i click the arrow on the left side of the popup, it always displays "NSObject" as the only property.
BeachRunnerJoe
Yeah, well, see the little "uppy downy" looking arrows between the arrow and the name of the object? Click that. There'll be a "Print Description" option in there. See if that tells you anything.You can also use "po" in the console to print the description of a variable, of course...
Dan Ray
i tried that, all it prints is "<NSDateComponents: 0xbc291a0>"
BeachRunnerJoe
+1  A: 

It's frustrating. The debugger has to know the structure of every object and it apparently doesn't. It used to be much worse, though. Like with NSArray's, they're an array of objects. The debugger doesn't know what type of objects specifically, and that's due to the Objective-C language, not the debugger.

As you dive into iOS development, I think you're going to find that Apple is about 15 years behind its competitors when it comes to development. That's no joke. But they're catching up and, trust me, it used to be much worse!

beeeefy
Wow, that's too bad. Oh well, I guess I'll go back to use a bunch of NSLog statements :( I haven't had to use the "print-to-screen" method of debugging since I wrote assembly code over ten years ago. Ok, I'll stop whining now. Thanks again!
BeachRunnerJoe