iOS:如何在调试时观察 NSManagedObject 属性
正如标题所说,我想调试一些 Core Data 的 bug。是否可以在 XCode 4 的监视窗口中监视实体的属性,而不是在代码中到处使用 NSLog
?就像.NET的Entity Framework 4.0中的“快速监视”工具一样。
As the title said, I want to debug some Core Data bugs. Instead of using NSLog
everywhere in the code, is it possible to watch a entity's attributes in XCode 4's watch window? Like the "quick watch" tool in Entity Framework 4.0 of .NET.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
任何分配有命名变量的值都可以在调试器中查看。在 Xcode 4 中,它出现在调试器的左列中。如果选择该变量,则可以使用上下文菜单选项“打印到控制台”将详细说明打印到调试器控制台。这在检查托管对象时非常有用,因为它们通常包含比变量列表可以清晰显示的信息更多的信息。
(请参阅 Xcode 4 转换指南:控制程序在调试区域和源代码编辑器中执行,图 5-9
此外,您可以从调试器控制台中的命令行发出任何标准 gdb 命令,其中最有用的是。
po
代表print object
。假设您有一个具有属性aProperty
的对象。直接使用:如果您创建 NSManagedObject 子类,您还可以选择覆盖
description
方法,该方法允许您生成对象的自定义描述,该描述将显示在print to console< /代码> 和po 命令。
Any value that has a named variable assigned to it can be viewed in the debugger. In Xcode 4 it appears in the debugger's left column. If you select the variable, you can use the contextual menu option "Print to console" to have a detailed description printed to the debugger console. This is useful when examining managed objects as they often contain more info than the list of variables can cleanly display.
(See- Xcode 4 Transition Guide:Control Program Execution in the Debug Area and Source Editor, Figure 5-9
In addition, you can issue any of the standard gdb commands from the command line in the debugger console. The most useful of the these commands is
po
which stands forprint object
. Say you have an objectmyObject
that has a propertyaProperty
. You could examine it directly by using:If you create NSManagedObject subclasses, you also have the option of overriding the
description
method which allows you to produce custom descriptions of the object which will show up inprint to console
and thepo
command.