我的NSString值为@"78000".我如何以货币格式获得此信息,即78,000美元,其余为NSString.
您需要使用数字格式化程序.请注意,这也是您以用户区域设置的正确格式显示日期/时间等的方式
// alloc formatter NSNumberFormatter *currencyStyle = [[NSNumberFormatter alloc] init]; // set options. [currencyStyle setFormatterBehavior:NSNumberFormatterBehavior10_4]; [currencyStyle setNumberStyle:NSNumberFormatterCurrencyStyle]; NSNumber *amount = [NSNumber numberWithInteger:78000]; // get formatted string NSString* formatted = [currencyStyle stringFromNumber:amount] [currencyStyle release];