You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tauri-plugins-workspace/plugins/camera/ios/Sources/ImageSaver.swift

20 lines
535 B

import UIKit
class ImageSaver: NSObject {
var onResult: ((Error?) -> Void) = {_ in }
init(image: UIImage, onResult:@escaping ((Error?) -> Void)) {
self.onResult = onResult
super.init()
UIImageWriteToSavedPhotosAlbum(image, self, #selector(saveResult), nil)
}
@objc func saveResult(_ image: UIImage, didFinishSavingWithError error: Error?, contextInfo: UnsafeRawPointer) {
if let error = error {
onResult(error)
} else {
onResult(nil)
}
}
}