Arrays 如何将json中的双值转换和设置为函数

Arrays 如何将json中的双值转换和设置为函数,arrays,json,swift,uitableview,alamofire,Arrays,Json,Swift,Uitableview,Alamofire,我的问题是:使用alamofire,我需要将坐标传递给位置变量中的函数(经度、纬度)。我已成功获取数据,但无法将其添加到函数中。该函数在MapViewController.swift中称为“showSomeMarkers”。谢谢 代码: 型号: class Model: NSObject { var name: String var lat: Double var lng: Double init(with modelDictionary: [Stri

我的问题是:使用alamofire,我需要将坐标传递给位置变量中的函数(经度、纬度)。我已成功获取数据,但无法将其添加到函数中。该函数在MapViewController.swift中称为“showSomeMarkers”。谢谢

代码:

型号:

class Model: NSObject {

    var name: String
    var lat: Double
    var lng: Double
    
    init(with modelDictionary: [String: Any]) {
        name = modelDictionary["name"] as? String ?? ""
        lat = modelDictionary["lat"] as? Double ?? 0.0
        lng = modelDictionary["lng"] as? Double ?? 0.0
    }
}
单元格:


由于表视图需要Json中的1个数据类型字符串,所以我在单元格中配置值。请帮忙。谢谢

将您的函数更改为

func showSomeMarkers (latitude: Double, longitude: Double) {
    let position = CLLocationCoordinate2D(latitude: latitude , longitude: longitude)
    //rest of code
}
并从getValues中的闭包调用它

func getValues() {
    Networking.shared.getAllValues(value: "/kyiv/places") { coordinates in
        self.coordinates = coordinates
        for coordinate in self.coordinates {
            showSomeMarkers(latitude: coordinate.lat, longitude: coordinate.lng)
        }
        self.tableView.reloadData()
    }
}

请告诉我你到底想要什么?您从服务器获得的纬度和经度的数据类型是什么?你的问题陈述不清楚?对不起,用你自己的语言以外的语言表达想法是相当困难的。Lotitude和longitude是双精度的(函数也应该有双精度的,但是我忘了删除int)。我需要获取经度和纬度(双类型)的值,并将它们注入到函数中。我无法提供此数据的正确路径。另外,我需要做3个标记,我可能需要创建一个数组,我不知道。这个链接是我的json:,希望对你有所帮助。谢谢!你是我的救世主。通过一个坐标而不是一个坐标不是更容易吗?
func showSomeMarkers (latitude: Double, longitude: Double) {
    let position = CLLocationCoordinate2D(latitude: latitude , longitude: longitude)
    //rest of code
}
func getValues() {
    Networking.shared.getAllValues(value: "/kyiv/places") { coordinates in
        self.coordinates = coordinates
        for coordinate in self.coordinates {
            showSomeMarkers(latitude: coordinate.lat, longitude: coordinate.lng)
        }
        self.tableView.reloadData()
    }
}