通貨文字列を10進数値に変換するための数値書式設定があります。問題は、テキスト文字列に先頭のドル記号( "$")がない場合、有効な一致番号ではなく0に変換されることです。だから、:ここに
"$3.50" converts to 3.50
"3.50" converts to 0
は、コンバータのコードです:
// formatter to convert a value to and from a currency string
NSNumberFormatter *currencyFormatter = [[NSNumberFormatter alloc] init];
[currencyFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
[currencyFormatter setGeneratesDecimalNumbers:YES];
私は何かが足りないのですか?