To get the result, you must implement the DocumentDetectorControllerDelegate delegate in your controller:
classYouController:UIViewController, DocumentDetectorControllerDelegate{// MARK: - Document Detection DelegatesfuncdocumentDetectionController(_scanner: DocumentDetectorController, didFinishWithResultsresults: DocumentDetectorResult) {//Called when the process was successfully executed//The result variable contains the data obtained }funcdocumentDetectionControllerDidCancel(_scanner: DocumentDetectorController) {// Called when the user cancel }funcdocumentDetectionController(_scanner: DocumentDetectorController, didFailWithErrorerror: DocumentDetectorFailure) {//Called when the process terminate with an error//The error variable contains info about error }}
After creating the DocumentDetector object, start the DocumentDetectorController by passing this object as a parameter in the constructor:
let scannerVC =DocumentDetectorController(documentDetector: documentDetector)scannerVC.documentDetectorDelegate = selfpresent(scannerVC, animated:true, completion:nil)