在 Xcode 调试器中查看 NSMutableArray 中的 NSString 值有什么技巧吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2325517/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 19:08:25  来源:igfitidea点击:

Is there a trick to see NSString values in an NSMutableArray in Xcode debugger?

iphonexcodedebuggingnsstringnsarray

提问by dontWatchMyProfile

When I debug, I never get the value of an NSString inside of an array. All I see are cryptic symbols, probably memory addresses of something like 0x1dc3753. I dig into all the stuff and expand everything, but no humanly readable value at all. Not really useful at all. How do you go about this (besides NSLogging everything)?

当我调试时,我永远不会在数组中获得 NSString 的值。我看到的都是神秘符号,可能是诸如 0x1dc3753 之类的内存地址。我深入研究了所有内容并扩展了所有内容,但根本没有人类可读的价值。一点用都没有。你如何处理这个(除了 NSLogging 一切)?

采纳答案by TechZen

You should be able to see at least an abbreviated string in the variables pane when you expand a NSMutableArray. If you can't, that suggest you don't actually have strings as elements.

当您展开 NSMutableArray 时,您应该至少能够在变量窗格中看到一个缩写的字符串。如果你不能,那表明你实际上没有将字符串作为元素。

In the variables pane, control-click and from the pop-up menu select Show Type Column. Then when you drilled down into the array, it will show you the class of each element.

在变量窗格中,按住 Control 键并单击并从弹出菜单中选择Show Type Column。然后当你深入到数组中时,它会显示每个元素的类。

回答by Stefan Arentz

Also, same thing as 'Print Description' is to type po variableNamein the debugger console.

此外,与“打印描述”相同的是po variableName在调试器控制台中键入。

回答by pheelicks

Set a breakpoint near the array you want to inspect and hover over the array variable. Then, hover just to right of the triangle that appears and you should have an icon appear which is two triangles (above each other). Click on this and select "Print description" from the menu.

在要检查的数组附近设置断点并将鼠标悬停在数组变量上。然后,将鼠标悬停在出现的三角形的右侧,您应该会出现一个图标,它是两个三角形(彼此重叠)。单击此按钮并从菜单中选择“打印说明”。