nsnumberformatter

    3熱度

    2回答

    我想通過使用「K」來表示數千,「M」來表示數百萬等等來縮短貨幣數量。 由於數字代表貨幣值,因此我還使用NSNumberFormatter根據其值,貨幣和設備的區域設置正確格式化每個數字。 我已經能夠單獨做1和2了,但是我很難一起做。起初,我試圖簡單地將縮寫附加到格式正確的輸出字符串NSNumberFormatter(例如,將「K」附加到「$ 10.3」以獲得「$ 10.3K」)。 這個工作對大多數

    0熱度

    2回答

    我試圖打印從JSON呼叫/訪問我的(雙)值,並得到: [事件緯度]:無法識別的選擇發送到實例0x8d09970 從同一對象訪問字符串值時,它打印得很好。在調試器中,我看到我的值和event.latitude被映射爲來自double的NSCFNumber。我不知道這是否僅僅是我沒有適當地投射或宣佈緯度,或者是沒有爲這個價值映射的東西。字符串的工作 下面是一些代碼: event.h @interfa

    5熱度

    2回答

    我有一個浮點數轉換爲字符串的函數: NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init]; [formatter setMaximumFractionDigits:2]; [formatter setMinimumFractionDigits:0]; NSString *finalNumber = [formatter

    0熱度

    1回答

    我正在使用Core Plot 1.1在iOS6中繪製簡單的散點圖。我正在使用以下代碼來正確格式化我的y軸,然後動態縮放到繪圖數據。 CPTXYAxis *y = axisSet.yAxis; y.labelingPolicy = CPTAxisLabelingPolicyAutomatic; y.minorTicksPerInterval = 3; y.preferredNumber

    0熱度

    3回答

    我試圖做一個標籤來顯示溫度,有超過100最多3個位數的溫度下,但我不希望任何小數... NSString *longtempstring = [tmp description]; NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init]; [formatter setMaximumFractionDigits

    4熱度

    3回答

    我使用NSNumberFormatter將用戶輸入轉換爲NSNumber(十進制數),我使用ARC。 NSNumberFormatter *f = [[NSNumberFormatter alloc] init]; [f setNumberStyle:NSNumberFormatterDecimalStyle]; [f setMaximumFractionDigits:1]; _myNum

    2熱度

    1回答

    我有一個UITextField,使用此代碼,打印底部標籤上的值並格式化它。 NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init]; [formatter setNumberStyle:NSNumberFormatterDecimalStyle]; [formatter setUsesGroupingSeparator:N

    1熱度

    2回答

    我有,我要轉換爲一個NSNumber一個NSString一個簡單的值。我在我的代碼中一直這樣做,出於某種原因,這次它不起作用。你看到有什麼問題嗎? NSNumberFormatter * num_formatter = [[NSNumberFormatter alloc] init]; [num_formatter setNumberStyle:NSNumberFormatterDecimalS

    1熱度

    1回答

    我們的質量保證團隊檢測到缺陷。當他們在貨幣字段中輸入0.095或0,095時,NSNumberFormatter將內容轉換爲95。 這是代碼,我們使用: + (NSNumber *) getNumberWithDecimalFromString:(NSString*) theSource { if ([TSCommons isEmpty:theSource]) return

    0熱度

    2回答

    我使用NSNumberFormatter和NSNumberFormatterCurrencyStyle在我的通用iOS應用程序中顯示應用程序購買價格。我的位置是印度,格式化程序在我測試的大多數設備(ipad模擬器,ipad 3設備,iphone 3gs設備,iphone 4設備)中正確顯示印度盧比符號。但是,只有在ipad第一代(運行iOS 5.1.1)時,它會顯示一個正方形而不是盧比符號。 所有