iOS 显示文件大小

// 显示文件大小
- (NSString *)transformedValue:(double)value {
    int multiplyFactor = 0;
    NSArray *tokens = [NSArray arrayWithObjects:@"bytes",@"KB",@"MB",@"GB",@"TB",@"PB", @"EB", @"ZB", @"YB",nil];
    while (value > 1024) {
        value /= 1024;
        multiplyFactor++;
    }
    return [NSString stringWithFormat:@"%4.2f %@", value, [tokens objectAtIndex:multiplyFactor]];
}

你可能感兴趣的:(iOS 显示文件大小)