Created
June 2, 2021 19:20
-
-
Save sgl0v/5f5397339a0e773903ffa5dda1e55df0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final class ImageScanner: NSObject { | |
private var completion: Completion? | |
func image(with completion: @escaping Completion) { | |
guard self.completion == nil, UIImagePickerController.isSourceTypeAvailable(.camera) else { | |
completion(.failure(ImageProviderError.startFailure)) | |
return | |
} | |
self.completion = completion | |
let pickerController = UIImagePickerController() | |
pickerController.delegate = self | |
pickerController.sourceType = .camera | |
UIViewController.topmostViewContoller.present(pickerController, animated: true) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment