Created
October 15, 2017 19:54
-
-
Save AlexandrFadeev/a1637a84dc7f491b41e8d842bee0f1b9 to your computer and use it in GitHub Desktop.
Covert bytes to megabytes in swift
This file contains 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
let bcf = ByteCountFormatter() | |
bcf.allowedUnits = [.useMB] // optional: restricts the units to MB only | |
bcf.countStyle = .file | |
let string = bcf.string(fromByteCount: Int64(data.count)) | |
print("formatted result: \(string)") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment