refactored code structure

This commit is contained in:
Micha
2025-11-17 15:42:55 +01:00
parent 22b2c632a9
commit 4efe1a2324
26 changed files with 417 additions and 29 deletions

View File

@@ -0,0 +1,23 @@
//
// ByteFormatting.swift
// iKeyMon
//
// Created by tracer on 01.04.25.
//
import Foundation
extension Int {
func toNiceBinaryUnit() -> String {
let units = ["B", "KB", "MB", "GB", "TB", "PB"]
var value = Double(self)
var index = 0
while value >= 1024 && index < units.count - 1 {
value /= 1024
index += 1
}
return String(format: "%.2f %@", value, units[index])
}
}