在XCode调试器中显示NSDecimal值 [英] Displaying NSDecimal values in XCode debugger

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

问题描述

在使用XCode 5进行调试会话期间,如何显示NSDecimal变量的实际值?我发现了这个问题,但这对我不起作用。输入 {(int)[$ VAR intValue]} 之类的摘要描述只会导致出现消息摘要不可用。我应该补充一点,我的NSDecimals位于数组中( NSDecimal dataPoint [2]; )。

During a debug session with XCode 5, how would I display the actual value of an NSDecimal var? I found this question but that doesn't work for me. Entering a summary description like {(int)[$VAR intValue]} just results in a message "Summary Unavailable". I should add that my NSDecimals are in an array (NSDecimal dataPoint[2];).

使用调试控制台通过上下文菜单或使用p dataPoint [0] 打印var描述只是给了我原始的NSDecimal视图:

Using the debug console to either print the var description via the context menu or by using p dataPoint[0] just gives me the raw NSDecimal view:

Printing description of dataPoint[0]:
(NSDecimal) [0] = {
  _exponent = -1
  _length = 1
  _isNegative = 0
  _isCompact = 1
  _reserved = 0
  _mantissa = {
    [0] = 85
    [1] = 0
    [2] = 42703
    [3] = 65236
    [4] = 65534
    [5] = 65535
    [6] = 23752
    [7] = 29855
  }
}


推荐答案

最简单方法是在调试器中将其转换为 NSDecimalNumber ,即

The easiest way is to turn it into an NSDecimalNumber in the debugger, i.e.

po [NSDecimalNumber decimalNumberWithDecimal:dataPoint[0]]

这将创建一个新的 NSDecimalNumber 打印出一个漂亮的说明。您问题中的 NSDecimal 是8.5。

This will create a new NSDecimalNumber which prints a nice description. The NSDecimal in your questions is 8.5.

(lldb) po [NSDecimalNumber decimalNumberWithDecimal:dataPoint[0]]
8.5

如果要显示数字在变量视图中,其摘要格式为:

If you want to have the number displayed in the Variable View, the Summary Format for it would be:

{[NSDecimalNumber decimalNumberWithDecimal:$VAR]}:s

这篇关于在XCode调试器中显示NSDecimal值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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