당신은 NSNumberFormatter를 서브 클래 싱해야합니다
예 :
@implementation LTNumberFormatter
@synthesize abbreviationForThousands;
@synthesize abbreviationForMillions;
@synthesize abbreviationForBillions;
-(NSString*)stringFromNumber:(NSNumber*)number
{
if (! (abbreviationForThousands || abbreviationForMillions || abbreviationForBillions))
{
return [super stringFromNumber:number];
}
double d = [number doubleValue];
if (abbreviationForBillions && d > 1000000000)
{
return [NSString stringWithFormat:@"%@ %@", [super stringFromNumber:[NSNumber numberWithDouble:d/1000000000]], abbreviationForBillions];
}
if (abbreviationForMillions && d > 1000000)
{
return [NSString stringWithFormat:@"%@ %@", [super stringFromNumber:[NSNumber numberWithDouble:d/1000000]], abbreviationForMillions];
}
if (abbreviationForThousands && d > 1000)
{
return [NSString stringWithFormat:@"%@ %@", [super stringFromNumber:[NSNumber numberWithDouble:d/1000]], abbreviationForThousands];
}
return [super stringFromNumber:number];
}
@end
이 중복되지 않습니다. 파일 크기를 언급하지 않습니다. –