[英]xcode: how to debug in xcode?
I have a Person class which has only a property: name. 我有一个Person类,它只有一个属性:name。 I want to list the property value when debug, but xcode just display "isa", how can I do it like in eclipse?
我想在调试时列出属性值,但是xcode仅显示“ isa”,我该如何在eclipse中实现呢?
Xcode : Xcode:
eclipse: 日食:
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. 可以使用
name
方法读取名为name
的属性,并可以使用setName:
方法对其进行设置。 You can use the debugger's po
command to print a description of an object. 您可以使用调试器的
po
命令来打印对象的描述。 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. po
命令通过将debugDescription
消息发送到要打印的对象来工作,默认情况下, debugDescription
仅发送description
消息。 So you could add this method to your Person
class: 因此,您可以将此方法添加到
Person
类中:
- (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>
如果rob的帖子不起作用,那么我将尝试在控制台中输入bt(用于回溯)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.