首页 > 解决方案 > 线程 0 因 ARM 线程状态(64 位)而崩溃

问题描述

我将我的应用程序提交到应用程序商店,他们说应用程序启动时崩溃。但是对于我在模拟器中的设备和它的工作正常。无法在这里找到问题所在。

我附上了苹果给我的带有崩溃文件的二进制图像。请让我知道任何能够解决问题的 1。

这是崩溃文件

谢谢

在此处输入图像描述

崩溃显示在这里:

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   WCi                             0x0000000100df0454 specialized closure #1 in MainScreenViewController.getAdressName(coords:) + 509012 (MainScreenViewController.swift:668)
1   WCi                             0x0000000100e01ed4 partial apply for closure #1 in MainScreenViewController.getAdressName(coords:) + 581332 (MainScreenViewController.swift:0)
2   WCi                             0x0000000100de0288 _T0SaySo11CLPlacemarkCGSgs5Error_pSgIegxx_So7NSArrayCSgSo7NSErrorCSgIeyByy_TR + 443016 (MainScreenViewController.swift:0)
3   libdispatch.dylib               0x00000001d96596c8 0x1d95f9000 + 394952
4   libdispatch.dylib               0x00000001d965a484 0x1d95f9000 + 398468
5   libdispatch.dylib               0x00000001d96069a4 0x1d95f9000 + 55716
6   CoreFoundation                  0x00000001d9bb0df4 0x1d9b05000 + 703988
7   CoreFoundation                  0x00000001d9babcbc 0x1d9b05000 + 683196
8   CoreFoundation                  0x00000001d9bab1f0 0x1d9b05000 + 680432
9   GraphicsServices                0x00000001dbe24584 0x1dbe19000 + 46468
10  UIKitCore                       0x0000000206b38c00 0x206250000 + 9341952
11  WCi                             0x0000000100dbeba4 main + 306084 (AppDelegate.swift:23)
12  libdyld.dylib                   0x00000001d966abb4 0x1d966a000 + 2996

所以在我的MainScreenViewController.swift

 func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {


        if  firstload == false  {
            firstload = true
            firstTimeLoads = true
            currentlocation = locations.last!
            let cityCoords = CLLocation(latitude: currentlocation.coordinate.latitude, longitude: currentlocation.coordinate.longitude)
            let addresss = getAdressName(coords: cityCoords)
            self.userlat =  "\(currentlocation.coordinate.latitude)"
            self.userlong = "\(currentlocation.coordinate.longitude)"
            self.userDevice = "iOS"
            self.userName = Uname ?? "NA"
            self.userId = UId ?? "NA"
            self.userTime = time


            let camera = GMSCameraPosition.init(target: currentlocation.coordinate, zoom: 11, bearing: 0, viewingAngle: 0)
            passloc = String(format: "%f,%f", currentlocation.coordinate.latitude,currentlocation.coordinate.longitude)
            if let locationData = passloc {
                self.movelocation = currentlocation
                UserDefaults.standard.set(locationData, forKey: "storemyloc")
                UserDefaults.standard.synchronize()
                viewmap.animate(to: camera)
                self.getAddressFromLatLon(location: currentlocation)
                print("my address")
                print(currentlocation)

                print("LOG: LOCATION 1 \(searchlocation)")
                if CLLocationCoordinate2DIsValid(self.searchlocation.coordinate) {
                    self.movelocation = self.searchlocation
                } else {
                    self.runlink()
                }
            }
        }
    }

func getAdressName(coords: CLLocation) {

    CLGeocoder().reverseGeocodeLocation(coords) { (placemark, error) in
        if error != nil {
            print("Hay un error")
        } else {

            let place = placemark! as [CLPlacemark]
            if place.count > 0 {
                let place = placemark![0]
                var adressString : String = ""


                if place.locality != nil {
                    adressString = adressString + place.name! + " - "
                }
                if place.thoroughfare != nil {
                    adressString = adressString + place.subLocality! + ", "
                }

                if place.locality != nil {
                    adressString = adressString + place.subAdministrativeArea! + " - "
                }

                if place.country != nil {
                    adressString = adressString + place.country!
                }
               self.Userdic.setValue(adressString, forKey: "useraddress")
                self.userAdd = adressString
            }
        }
    }
}

那次崩溃可能是什么问题?坐标 - 纬度,经度未通过或问题与func getAdressName(coords: CLLocation)

标签: ioslocationapp-store

解决方案


getAdressName用下面的代码替换你的。

func getAdressName(coords: CLLocation) {

        CLGeocoder().reverseGeocodeLocation(coords) { (placemark, error) in
            if error != nil {
                print("Hay un error")
            } else {

                let place = placemark! as [CLPlacemark]
                if place.count > 0 {
                    let place = placemark![0]
                    var adressString : String = ""


                    if place.name != nil {
                        adressString = adressString + place.name! + " - "
                    }
                    if place.subLocality != nil {
                        adressString = adressString + place.subLocality! + ", "
                    }

                    if place.subAdministrativeArea != nil {
                        adressString = adressString + place.subAdministrativeArea! + " - "
                    }

                    if place.country != nil {
                        adressString = adressString + place.country!
                    }
                   self.Userdic.setValue(adressString, forKey: "useraddress")
                    self.userAdd = adressString
                }
            }
        }
    }

您检查 nil的值,locality但在内部获取place.subAdministrativeArea!which 的值可能在 nil 的情况下。


推荐阅读