ObjC/Cocoa class for converting size to human-readable string?

Starting in OS X 10.8 and iOS 6, you can use NSByteCountFormatter.

Your example would look like this:

[NSByteCountFormatter stringFromByteCount:20000000 countStyle:NSByteCountFormatterCountStyleFile];

Leave a Comment