0
說我有一個字符串是23.56英鎊或23.56美元,我怎麼能把它轉換成-23.56?iPhone:如何將貨幣符號的字符串轉換爲負數?
我有這部分
NSMutableString *strAmount = [NSMutableString stringWithString:txtAmount.text];
[strAmount replaceCharactersInRange: [strAmount rangeOfString: strCurrencySymbol] withString:@""];
我收到上一個警告... 警告: 'NSDecimalNumber' 不能爲 '-descriptionWithLocale' 迴應還有一個錯誤 - [NSDecimalNumber descriptionWithLocale]:無法識別的選擇器發送到實例0x595cde0 ***終止應用程序由於未捕獲的異常'NSInvalidArgumentException',原因:' - [NSDecimalNumber descriptionWithLocale]:無法識別的選擇器發送到實例0x595cde 0' 終止在拋出'NSException'的實例後調用 – Jules 2010-09-28 09:11:58
抱歉。最後一條語句更新爲只使用'description' – falconcreek 2010-09-28 11:16:26