0

我在单击按钮时崩溃

        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]
        

在创建请求者变量的数组时。在模拟器代码上工作正常。并且分配给请求者的内存,但是当在设备上运行时请求者内存未初始化。

在此处输入图像描述

4

0 回答 0