0

I have a Person class which has only a property: name. I want to list the property value when debug, but xcode just display "isa", how can I do it like in eclipse?

Xcode :

eclipse:

enter image description here

2 Answers 2

3

Under the hood, properties are accessed using methods. A property named name can be read using the name method, and it can be set using the setName: method. You can use the debugger's po command to print a description of an object. Try typing this at the debugger console:

po [p name]

The po command works by sending the debugDescription message to the object you're printing, and by default, debugDescription just sends the description message. So you could add this method to your Person class:

- (NSString *)description {
    return [NSString stringWithFormat:@"<%@: %p name=%@>", self.class, self, self.name];
}

Then you can use a debugger command like this:

po p

and get output like this:

<Person: 0x10013fd60 name=Jack>
Sign up to request clarification or add additional context in comments.

2 Comments

thank you, so you mean I can't just list all properties in debug area? Or is there any way to do that? maybe using instance variable instead of property?
Not being able to see all instance variables is a problem in the current version of Xcode. You might have better luck by switching to the LLDB debugger (in your scheme settings), or you might just have to wait for a future version of Xcode and hope it's fixed.
1

If rob's post did not work, then i would try typing in bt (for backtrace) in the console

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.