我有多个位置动态地绘制在MapKit上。我想知道如何将我的当前纬度和经度放入一个单一的数组中,因为它们当前被打印为单独的对象,这不会像应该那样绘制地图。我知道问题所在,但不确定如何解决。以下是我目前用于生成坐标的代码 -
do {
let place = try myContext.executeFetchRequest(fetchRequest) as! [Places]
for coords in place{
let latarray = Double(coords.latitude!)
let lonarray = Double(coords.longitude!)
let arraytitles = coords.title!
let destination:CLLocationCoordinate2D = CLLocationCoordinate2DMake(latarray, lonarray)
print(destination)
} catch let error as NSError {
// failure
print("Fetch failed: \(error.localizedDescription)")
}
以下是在控制台中的打印输出 - 输出结果
我需要输出的打印格式能够正确运行 - 期望的输出结果
希望您能理解我的意思。非常感谢您的帮助!谢谢阅读。