I have a dynamic amount of locations being plotted onto a mapkit. I am curious on how I can get my current latitudes and longitudes into a single array, as they are currently being printed as separate objects which is not plotting not the map like it should. I know the problem but not sure how to fix it. Here is my current code to produce the coordinates -
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)")
}
And here is the print in the console - Output
What I need the print to look like to work correctly - Desired output
I hope you understand what I mean. I am very grateful of any help! Thank you for reading.