最新消息:20210917 已从crifan.com换到crifan.org

[已解决]Xcode调试时如何查看某个变量的值

Xcode crifan 7139浏览 0评论
Xcode调试期间,对于当前执行到的某行中的某个变量
想要查看其值:
want to see value of variable in xcode
但是就是找不到如何查看该变量的地方。。。
包括:
鼠标移动到该变量上面:
even mouse move on variable
也不显示变量值
也点击 左下角到:
Auto
Local Variable
All Variables,Registers,Global and Statics
change to auto mode not see value但是不方便,不能直接看到
而对于当前这个变量,由于是属于self的变量,所以是可以在All Variables中看到的:
can see value in all variables
但是:
还是尼玛的,太麻烦了。。。
更严重的是:
别的变量,
很多时候就很难找到了。。。很难查看到了。。。
搜:
xcode debug variable value
参考:
官网的这个截图
-》我之前偶尔可以遇到
-》但是现在是:鼠标移动上去,不显示值。。。
-》看了官网提示,才知道:
原来你妹的,需要是:
只有设置了断点,且鼠标移动到断点之前的变量,才能显示对应的值:
need set breakpoint and before value
而对于:
断点之后的,即使是,当前调试单步执行后的代码,鼠标移动到上面,是不显示值的。。。
参考:
去开启:
Running->Starts->Show debugger with Current Views
show debugger with current views

看看效果。

但是发现:
对于Pauses,本身已经选中这些选项了:
pause has doen those settings
不过,另外一个小窍门,有点用:
在调试区域,右击,打印变量的描述:
right click can show debug print values
print info in debug area
后来通过:
的评论:
“哈哈,不会用 lldb 的家伙,抱怨是必然的”
去试试:
lldb
-》
原来之前别人帖子中提到的:
po xxx
中的po,指的是:
lldb中的功能啊。
所以:
以后想要查看变量的值,可以试试po了:
-》即使lldb的命令行可以实现很多功能
-》但是为了调试时查看变量的值,也还是很麻烦啊
-》不能直接鼠标移动上去就显示值,搞得还要手动输入,够烦
(lldb) expr -O — [SomeClass returnAnObject]
Or use the po alias:
(lldb) po [SomeClass returnAnObject]
po some value print value
again po other values to see values
[总结]
Xcode调试期间,如果鼠标移动上去,变量值无法显示的话,则可以用:
调试界面中的lldb中输入:
  • po variableName
  • po instance.propertyName
  • po expression
即可输出:
  • 变量值
  • 某个类的实例的某个属性
  • 函数调用的返回值
  • 了。
-》虽然比:
鼠标移动上去就显示变量值
麻烦点,而需要手动输入,但是还是比
无法查看到变量的值
要好很多
->总的说就做:聊胜于无
-》Xcode和Windows下的Visual Studio,Eclipse等IDE工具相比,调试功能简直弱的成渣啊

转载请注明:在路上 » [已解决]Xcode调试时如何查看某个变量的值

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
94 queries in 0.206 seconds, using 23.36MB memory