小编Pie*_*lon的帖子

如何在swift中获取数组中元组的第一个元素

我有一个内置一些元组的数组.如何在数组中获得该元组的第一项?

let cars = [("cars","cycles"),("stairs","escalator"),("table","chair")]
Run Code Online (Sandbox Code Playgroud)

我想得到每个元组中的第一项结果应该是"汽车","楼梯","桌子"

arrays tuples swift

10
推荐指数
1
解决办法
5674
查看次数

如何使用swift设置多个注释的数组

如何设置下面的数组.我试图在我的地图上添加多个注释.我能够在stackoverflow上找到下面的代码,但是他们没有展示如何设置数组.

var objects = [ 
                //how should the array be setup here 
              ]

for objecters in objects!{
    if let latit = objecters["Coordinates"]["Latitude"]{
        self.latitudepoint = latit as! String
        self.map.reloadInputViews()
    }
    else {
        continue
    }
    if let longi = objecters["Coordinates"]["Longitude"]{
        self.longitudepoint = longi as! String
        self.map.reloadInputViews()
    }
    else {
        continue
    }
    var annotation = MKPointAnnotation()
    var coord = CLLocationCoordinate2D(latitude: Double(self.latitudepoint)!,longitude: Double(self.longitudepoint)!)
    mapView.addAnnotation(annotation)
}
Run Code Online (Sandbox Code Playgroud)

arrays mkannotation ios mkpointannotation swift

8
推荐指数
1
解决办法
1万
查看次数

标签 统计

arrays ×2

swift ×2

ios ×1

mkannotation ×1

mkpointannotation ×1

tuples ×1