2016-12-16 7 views
0

Screenshotこんにちは私はブロック内のブロックを呼び出していますが、エラーlibC++ abi.dylibでクラッシュしています。コンソールには他の説明は表示されません。問題を見つけることができません。エラーでクラッシュするlibC++ abi.dylib:NSException型のキャッチされていない例外で終了する

 GeocoderApi.shared.getAddress(lat: "\(coordinate.latitude)", lang: "\(coordinate.longitude)", reverseGeocodeHandler: { status, responseObject in 
     if let locality = responseObject as? String{ 
      WeatherApi.shared.averageForecastName(cityName: locality, completionHandler: { status, responseObject in 
       LocationManager.shared.stopUpdatingLocation() 
       if let weatherArray = responseObject as? [Weather]{ 
        if !weatherArray.isEmpty { 
         self.myJourney.weatherArray.remove(at: 0) 
         self.myJourney.weatherArray.insert(weatherArray[0], at: 0) 
         self.myJourney.weatherArray[0].upcomings.append(contentsOf: weatherArray) 
         self.myJourney.weatherArray[0].upcomings.remove(at: 0) 
         self.journeyView.reloadWeather() 
        } 
       } 
      }) 
     } 
    }) 

func getAddress(lat:String,lang:String,reverseGeocodeHandler:@escaping (_ status:Bool, _ responseObject:Any)->()){ 

    if !ReachabilityManager.shared.isReachable { 
     let error = WSError() 
     error.errorTitle = "Network error" 
     error.errorDescription = "Unable to connect, please check your internet connectivity." 
     reverseGeocodeHandler(false,error) 
     return 
    } 

    self.showNetworkActivity() 

    let sessionManager = AFHTTPSessionManager(baseURL: baseUrl, sessionConfiguration: URLSessionConfiguration.default) 
    sessionManager.requestSerializer = AFJSONRequestSerializer() 
    sessionManager.responseSerializer = AFJSONResponseSerializer() 
    let urlPath = getPath(path: "maps/api/geocode/json?latlng=\(lat),\(lang)") 

    sessionManager.post(urlPath, parameters: nil, progress: { progress in 

    }, success: { task, responseObject in 
     var cityName = "" 

     if let disc = responseObject as? [String:Any]{ 
      cityName = self.Parse(disc: disc) 
     } 
     self.hideNetworkActivity() 

     reverseGeocodeHandler(true,cityName) 

    }, failure: { operation, err in 
     self.hideNetworkActivity() 
     let error = WSError(error: err as NSError) 
     reverseGeocodeHandler(false,error) 

    }) 
} 

func averageForecastName(cityName:String,completionHandler:@escaping (_ status:Bool, _ responseObject:Any)->()){ 

    if !ReachabilityManager.shared.isReachable { 
     let error = WSError() 
     error.errorTitle = "Network error" 
     error.errorDescription = "Unable to connect, please check your internet connectivity." 
     completionHandler(false,error) 
     return 
    } 

    self.showNetworkActivity() 

    let sessionManager = AFHTTPSessionManager(baseURL: baseUrl, sessionConfiguration: URLSessionConfiguration.default) 
    sessionManager.requestSerializer = AFJSONRequestSerializer() 
    sessionManager.responseSerializer = AFJSONResponseSerializer() 
    let urlPath = getPath(path: "data/2.5/forecast/daily?q=\(cityName)&cnt=6") 

    sessionManager.post(urlPath, parameters: nil, progress: { progress in 

    }, success: { task, responseObject in 
     var weatherArray = [Weather]() 

     if let disc = responseObject as? [String:Any]{ 
      weatherArray.append(contentsOf: Weather.GetForecasts(rootDisc: disc)) 
     } 
     self.hideNetworkActivity() 

     completionHandler(true,weatherArray) 

    }, failure: { operation, err in 
     self.hideNetworkActivity() 
     let error = WSError(error: err as NSError) 
     completionHandler(false,error) 

    }) 
} 
+0

を誰もが理由を説明できますか? –

+0

'URLString'は' nil'です。私は何かが 'urlPath'で怪しいと思う。 – shallowThought

+0

はい、それはエンコードの問題でした –

答えて

0

は(withAllowedCharacters:.urlQueryAllowed).addingPercentEncodingことによってそれを解決し

関連する問題