Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

1458279

Suspended
Original poster
May 1, 2010
1,601
1,521
California
Is there a way, either in the debugger (LLDB) or something else, to see the structure of an object?

I'd like see the initializer and all methods of a given object. Maybe a breakdown of what's inherited, return types, current value (using debugger).

I know the stock classes can be viewed in the documentation, I'm concerned about custom classes/objects.

Edit: If someone has a good tutorial about the debugger that would be great. I've seen the stock Apple ones, but I'd like to have much more in depth, mainly about watching variables/objects/structures...
 
Is there a way, either in the debugger (LLDB) or something else, to see the structure of an object?

I'd like see the initializer and all methods of a given object. Maybe a breakdown of what's inherited, return types, current value (using debugger).

I know the stock classes can be viewed in the documentation, I'm concerned about custom classes/objects.

Edit: If someone has a good tutorial about the debugger that would be great. I've seen the stock Apple ones, but I'd like to have much more in depth, mainly about watching variables/objects/structures...

The answer is "sort of." If you look at the variables pane of the debugger area when you hit a breakpoint, it shows local variables and parameters for the current function, and will also show an entry (at the top) called "self". If you expand that, you'll see the instance variables of the current class. There will also be an entry for the current class's immediate base class.

So, for the object that's in scope, you can see the hierarchy of instance variables for the current class and it's ancestor classes.

Another way to learn things is by logging objects. If you display an object using po (print-object) and a variable name, the debugger tries to invoke a method called description on the current object. The method description should take no parameters, and return an NSString that describes the current object. If you don't provide a description method, the system will walk down the inheritance chain looking for an ancestor class that implements the method. If it gets all the way to NSObject, you get very basic information about the object.

You can write description methods for your classes that display all their instance variables, and then also call the base class's description method. Do that for your whole inheritance chain and you can start to get an idea of the ancestry of your object.
 
Thanks Duncan!

Some languages I've used in the past have had "source code documenting" programs. They would go in and give a summary of the classes, etc.

Is there any program that will take ObjC source files and make a chart or some documentation showing classes with their init,setters,inst vars, etc...

The reason I'm asking, is that I'm following another Stanford U tutorial and the professor skipped a part. As an exercise, I'm forcing myself to find the problem. He sets up classes like Card, Deck, PlayingCard, etc. One array is not setup and I'm trying to find the problem. I have another students source code, but it's for a final project and I'm trying to understand why this part of the project is not working.

In case someone is doing the 2012 Stanford U tutorial, it's a card flipping game. The error is where the cards are being assigned a random card. I've gone thru the videos a few times, but he skips over a part that I can't seem to find.
 
Thanks Duncan!

Some languages I've used in the past have had "source code documenting" programs. They would go in and give a summary of the classes, etc.

Is there any program that will take ObjC source files and make a chart or some documentation showing classes with their init,setters,inst vars, etc...

The reason I'm asking, is that I'm following another Stanford U tutorial and the professor skipped a part. As an exercise, I'm forcing myself to find the problem. He sets up classes like Card, Deck, PlayingCard, etc. One array is not setup and I'm trying to find the problem. I have another students source code, but it's for a final project and I'm trying to understand why this part of the project is not working.

In case someone is doing the 2012 Stanford U tutorial, it's a card flipping game. The error is where the cards are being assigned a random card. I've gone thru the videos a few times, but he skips over a part that I can't seem to find.


In Xcode there is the "symbol navigator" which shows a hierarchical view of your classes and methods.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.