Converting byte sizes into human readable strings

The attached class is an NSFormatter subclass and is useful for taking a size expressed in byte like “2048” and convert it to an human readable string like “2 KB”. It supports unit of measures up to the Terabyte. Note that this class assumes it receives as input an NSNumber or any object that responds to floatValue. Backward translation is also not implemented (and wouldn’t probably make sense as informations are going to be lost anyways).

Download BRByteFormatter Class

Comments are closed.