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

前端 未结 8 1867
被撕碎了的回忆
被撕碎了的回忆 2020-11-28 05:41

Is there a simple way to do something like..

[NSMagicDataConverter humanStringWithBytes:20000000]

..which would return \"19.1MB\"?

8条回答
  •  北海茫月
    2020-11-28 06:10

    You can use FormatterKit and its TTTUnitOfInformationFormatter class:

    https://github.com/mattt/FormatterKit

    It is also available through CocoaPods with:

    pod 'FormatterKit', '~> 1.1.1'
    

提交回复
热议问题