SWIFT-can';无法获取response.result.issuess

SWIFT-can';无法获取response.result.issuess,swift,Swift,我做了一个天气应用程序,需要帮助。。。 我无法做出回应。结果。“isSuccess”但idk为什么? 看看我的代码: import UIKit import CoreLocation import Alamofire class WetterViewController: UIViewController, CLLocationManagerDelegate { // MARK: Outlet @IBOutlet weak var WetterImage: UIImageVi

我做了一个天气应用程序,需要帮助。。。 我无法做出回应。结果。“isSuccess”但idk为什么? 看看我的代码:

import UIKit
import CoreLocation
import Alamofire

class WetterViewController: UIViewController, CLLocationManagerDelegate
{
    // MARK: Outlet

    @IBOutlet weak var WetterImage: UIImageView!
    @IBOutlet weak var temperatureLabel: UILabel!
    @IBOutlet weak var StatusLabel: UILabel!

    // MARK: Properties

    let weatherURL = "http://api.openweathermap.org/data/2.5/weather"
    let appID = "3084f92d04fb27b6dd25f1a3a8afd221"

    var data: [String: String] = [:]
    {
        didSet
        {
            getWeatherData(from: weatherURL, with: data)
        }
    }

    let locationManager = CLLocationManager()

    // MARK: View Controller Life Cycle

    override func viewDidLoad()
    {
        super.viewDidLoad()

        locationManager.delegate = self
        locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters
        locationManager.requestWhenInUseAuthorization()
        locationManager.startUpdatingLocation()
    }

    // MARK: Methods

    func locationManager(_ manager: CLLocationManager, didUpdateLocations locations:     [CLLocation])
    {
        let location = locations[locations.count - 1]

        let latitude = String(location.coordinate.latitude)
        let longitude = String(location.coordinate.longitude)

        data = ["lat": latitude,
                "lon" : longitude,
                "appid": appID]
    }

    func getWeatherData(from url: String, with parameters: [String: String])
    {
        AF.request(url, method: .get, parameters: parameters).response { response in

            if response.result.isSuccess (but I can't get isSuccess, what is the problem?)
        }
    }
}

假设
response.result
Swift.result
类型,则应使用:

if value = try? response.result.get() {
    // Handle success
}

您是否尝试过调试此程序并检查您的输入参数设置为什么,以及在
响应中实际得到了什么?我检查了很多东西,但我无法解释一件可能相关的事情,那就是您在每次获得位置更新时调用Rest API,这可能意味着您进行了大量调用,这可能会导致您出错如果API对一段时间内可以进行的调用数量有限制,则返回。无论如何,如果您在调试器中运行它,或者添加一些打印语句,您应该会得到一些关于发生了什么的线索。idk。我是一个初学者,我的英语不是最好的,而且我不能解决它(我只想检查天气数据是否可以读取,我想写:-------------------------------------------------------------func-getWeatherData(来自url:String,带参数:[String:String]){AF.request(url,方法:.get,参数:parameters)。response{response in if-response.result.issucess(但我无法获得isSuccess和idk why…}}}在不同的框架中有几种
Result
类型,您可能需要澄清您指的是哪一种