I am getting crash on button click
let requester = VNRecognizeTextRequest { request, error in
guard let observations = request.results as? [VNRecognizedTextObservation] else {
fatalError("Received invalid observations")
}
for observation in observations {
guard let bestCandidate = observation.topCandidates(1).first else {
print("No candidate")
continue
}
if bestCandidate.string.contains(".") {
self.allTextString.append(" \(bestCandidate.string)")
}
print("Found this candidate: \(bestCandidate.string)")
}
if self.allTextString == "" {
self.showActionSheetTitleMessageOnMainThread("Temperature not found", message: "")
} else {
self.TempratureValue.text = self.allTextString
}
}
let requests = [requester]
While creating an array of the requester variable. On Simulator code works fine. And memory to requester is allocated , But when running on device requester memory is uninitialised.