要获取NSDecimal或NSDecimalNumber的无格式字符串表示形式,可以使用以下方法:
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setNumberStyle:NSNumberFormatterDecimalStyle];
NSString *formattedString = [formatter stringFromNumber:@(decimalValue)];
NSString *unformattedString = [formattedString stringByReplacingOccurrencesOfString:@"," withString:@""];
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setNumberStyle:NSNumberFormatterDecimalStyle];
NSString *formattedString = [formatter stringFromNumber:decimalNumber];
NSString *unformattedString = [formattedString stringByReplacingOccurrencesOfString:@"," withString:@""];
这样,您就可以获取NSDecimal或NSDecimalNumber的无格式字符串表示形式。
没有搜到相关的沙龙
领取专属 10元无门槛券
手把手带您无忧上云