Xcode领域调试问题 [英] Xcode debug issues with realm

查看:60
本文介绍了Xcode领域调试问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于为什么p self.sessionpo self.session返回不同的值,我有些困惑?

I'm a little confused as to why p self.session and po self.session are returning different values?

我应该信任哪个调试工具?看来我的对象是nil,但随后它也似乎不是.

Which one should I trust in my debugging? It would appear my object is nil but then it would also appear it isn't.

是我的session.messages零还是已设置??

Is my session.messages nil or is it set???

推荐答案

很简单,所以很简单:

1)lldb p命令(expr --的别名)对-"之后的表达式求值,然后在lldb中使用内存检查和数据格式化程序"机制(类型摘要和合成子代) ,请参见: http://lldb.llvm.org/varformats.html 了解更多信息)打印变量的值.

1) The lldb p command (an alias for expr --) evaluates the expression following the "--", and then uses memory inspection and the "data formatters" mechanism in lldb (type summaries & synthetic children, see: http://lldb.llvm.org/varformats.html for more details) to print the values of a variable.

2)lldb po命令(expr -O --的别名)对给定表达式求值,然后询问结果对象是否具有描述自身的方法(ObjC中的descriptiondebugDescription方法)或Swift中的Mirror),如果有,则打印该对象返回的字符串.如果不是,则返回#1的结果.

2) The lldb po command (an alias for expr -O --) evaluates the given expression, and then asks the resulting object whether is has a way of describing itself (a description or debugDescription method in ObjC or a Mirror in Swift) and if it does, prints the string returned by that object. If it doesn't, it returns the result of #1.

很有可能,Realm正在使用某些数据格式化程序通过ObjC的p呈现其对象,而对于Swift而言尚不存在.但是该对象仍然知道如何正确显示其调试描述,这就是po起作用的原因.

Most likely, Realm was using some data formatters to present their objects via p for ObjC and those don't exist for yet for Swift. But the object still knows how to present its debug description correctly, which is why po works.

这篇关于Xcode领域调试问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆