自定義方法
- (id)transformedValue:(id)value
{
? ?double convertedValue = [value doubleValue];
? ?int multiplyFactor = 0;
? ?NSArray *tokens = [NSArray arrayWithObjects:@"bytes",@"KB",@"MB",@"GB",@"TB",@“PB”, @“EB”, @“ZB”, @“YB”,nil];
? ?while (convertedValue > 1024) {
? ? ? ?convertedValue /= 1024;
? ? ? ?multiplyFactor++;
? ?}
? ?return [NSString stringWithFormat:@"%4.2f %@",convertedValue, [tokens objectAtIndex:multiplyFactor]];
}
系統(tǒng)自帶方法
[NSByteCountFormatter stringFromByteCount:1999 countStyle:NSByteCountFormatterCountStyleFile];