summaryrefslogtreecommitdiff
path: root/Hutch/Extensions/Int+ByteFormatting.swift
diff options
context:
space:
mode:
Diffstat (limited to 'Hutch/Extensions/Int+ByteFormatting.swift')
-rw-r--r--Hutch/Extensions/Int+ByteFormatting.swift8
1 files changed, 8 insertions, 0 deletions
diff --git a/Hutch/Extensions/Int+ByteFormatting.swift b/Hutch/Extensions/Int+ByteFormatting.swift
new file mode 100644
index 0000000..a17ece4
--- /dev/null
+++ b/Hutch/Extensions/Int+ByteFormatting.swift
@@ -0,0 +1,8 @@
+import Foundation
+
+extension Int {
+ /// Human-readable byte size string (e.g. "1.2 MB", "340 KB").
+ var formattedByteCount: String {
+ ByteCountFormatter.string(fromByteCount: Int64(self), countStyle: .file)
+ }
+}