當我研究了我在Trying to create NSDecimal in iPhone-Wax面臨的問題時,我現在的目標要低得多。如何在Wax中創建功能完整的NSDecimalNumber?試圖在蠟中創建誠實的NSDecimalNumber
我在AppDelegate.lua的頂部添加了以下兩行新鮮蠟項目。
local x = NSDecimalNumber:initWithString("2.3")
print(x)
print(x:class())
輸出是
(0x631e054 => 0x631d1a0) 2.3
(0x631e924 => 0x25f618) NSCFNumber
,而不是像
(0x621e834 => 0x620c550) <NSDecimalNumber: 0x620c550>
打開完整記錄在蠟給在調試窗口下面的跟蹤:
Creating class for WaxServer(0x621bf40)
Storing reference of class to userdata table WaxServer(0x621bf40 -> 0x621c454)
Storing reference to strong userdata table WaxServer(0x621bf40 -> 0x621c454)
Creating class for NSDecimalNumber(0x261120)
Storing reference of class to userdata table NSDecimalNumber(0x261120 -> 0x6205e44)
Storing reference to strong userdata table NSDecimalNumber(0x261120 -> 0x6205e44)
Creating instance for NSDecimalNumberPlaceholder(0x6213450)
Retaining instance for NSDecimalNumberPlaceholder(0x6213450 -> 0x621d7c4)
Storing reference of instance to userdata table NSDecimalNumberPlaceholder(0x6213450 -> 0x621d7c4)
Storing reference to strong userdata table NSDecimalNumberPlaceholder(0x6213450 -> 0x621d7c4)
Creating instance for NSCFNumber(0x620c550)
Retaining instance for NSCFNumber(0x620c550 -> 0x621e834)
Storing reference of instance to userdata table NSCFNumber(0x620c550 -> 0x621e834)
Storing reference to strong userdata table NSCFNumber(0x620c550 -> 0x621e834)
(0x621e834 => 0x620c550) 2.3
Creating class for AppDelegate(0x621ec50)
:
:
有兩件事是在這個日誌中顯示了我沒有要求的NSDecimalNumberPlaceholder和NSCFNumber。我相信這些是我悲痛的根源,我不知道他們來自哪裏。任何想法如何解決這個問題?
最終我想調用方法decimalValue,但蠟抱怨說它不能調用一個數字的方法。
如果它是一個不誠實的'NSDecimalNumber',它會有所作爲嗎? ;) –
@Dave DeLong:只要它可以轉換爲NSDecimal。 –