Kirill Kharkov
11/07/2022, 2:28 AMfunc writeImage(name: String, uiImage: UIImage) {
let data = uiImage.pngData()
let fileUrl = cachesDirectoryUrl.appendingPathComponent("\(name).png")
let filePath = fileUrl.path
fm.createFile(atPath: filePath, contents: data)
}
but in kotlin I don’t get where is my pngData or something similar. Sorry if it was discussed somewhere, I did my best to search but failed 🙂Kirill Kharkov
11/07/2022, 2:37 AMval data: NSData? = UIImagePNGRepresentation(avatarImage.image)
val filePath = NSURL("\\$file", relativeToURL = cachesDirectoryUrl).path ?: return
fileManager.createFileAtPath(filePath, data, null)
I still don’t quite get the logic behind such deviation in some APIs, so would appreciate to be enlightened 🙂russhwolf
11/07/2022, 2:47 AM