'value' is inaccessible due to 'internal' protection level

后端 未结 3 2022
傲寒
傲寒 2021-01-28 14:07

Setting up API for openweathermap. However, when it comes to setting up this:

func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [C         


        
3条回答
  •  说谎
    说谎 (楼主)
    2021-01-28 14:55

    Thanks for trying Alamofire 5! This error is a bit misleading, as the Swift compiler is trying to be helpful and letting you know there's an internal property value on response.result that you can't access. However, this is an internal Alamofire extension, as we moved to the Result type provided by the Swift standard library in Alamofire 5 beta 4. The system Result does not offer the the value and error properties that Alamofire's previously provided Result type did. So while we have extensions internally to provide functionality to us, they do not exist publicly for use by your app.

    The ultimate solution here is up to you. You can extend Result yourself to offer the properties (feel free to use the Alamofire implementation) or you can do without the properties and switch over the response.result value to extract the response value. I would suggest using switch for now, as it forces you to consider the .failure case.

提交回复
热议问题