0

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.

enter image description here

Community
  • 1
  • 1
  • See if these links are of any help - https://stackoverflow.com/questions/9225412/exc-bad-access-in-device-not-in-simulator and https://www.avanderlee.com/swift/exc-bad-access-crash/ – Knight Forked May 21 '20 at 11:49
  • Also checkout this - https://forums.developer.apple.com/thread/118520 – Knight Forked May 21 '20 at 11:50

0 Answers0