Since you want to display the file size for your user, NSByteCountFormatter is a good solution. It accepts NSData and can output a string representing the size of the data in a human-like format (e.g. 1 KB, 2 MB, etc.).
UIImage, UIImage NSData, , , UIImagePNGRepresentation() UIImageJPEGRepresentation(), NSData, . :
let data = UIImagePNGRepresentation(scaledImage)
let formatted = NSByteCountFormatter.stringFromByteCount(
Int64(data.length),
countStyle: NSByteCountFormatterCountStyle.File
)
println(formatted)
. (), NSByteCountFormatter. allowedUnits.
let data = UIImagePNGRepresentation(scaledImage)
let formatter = NSByteCountFormatter()
formatter.allowedUnits = NSByteCountFormatterUnits.UseBytes
formatter.countStyle = NSByteCountFormatterCountStyle.File
let formatted = formatter.stringFromByteCount(Int64(data.length))
println(formatted)