Created
March 21, 2018 18:46
-
-
Save vialyx/66ab9335f3ae76874edadc055a33328f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
let fileSizeInBytes: Int64 = 1924284 | |
let byteFormatter = ByteCountFormatter() | |
print("Default settigs: \(byteFormatter.string(fromByteCount: fileSizeInBytes))") | |
// Default settigs: 1.9 MB | |
byteFormatter.allowedUnits = .useKB | |
print("Change allowedUnits settig: \(byteFormatter.string(fromByteCount: fileSizeInBytes))") | |
// Change allowedUnits settig: 1,924 KB | |
byteFormatter.allowedUnits = .useAll | |
byteFormatter.isAdaptive = false | |
print("Change isAdaptive settig: \(byteFormatter.string(fromByteCount: fileSizeInBytes))") | |
// Change isAdaptive settig: 1.92 MB | |
byteFormatter.includesUnit = false | |
print("Change includesUnit settig: \(byteFormatter.string(fromByteCount: fileSizeInBytes))") | |
// Change includesUnit settig: 1.92 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment