Reputation: 2493
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:
Upvotes: 0
Views: 256
Reputation: 11
If rob's post did not work, then i would try typing in bt (for backtrace) in the console
Upvotes: 1
Reputation: 385500
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>
Upvotes: 3