I'm trying to create an array where the location of the user will be stored. I tried to use the code below but it won't work, it just change the coordinates inside the array.
func prevcurrLoc(lat : Double, lng: Double) {
var destination = [[String:Double]]()
let locArray : [String:Double] = ["lat" : lat, "lng" : lng]
destination.append(locArray)
print(destination)
}
I also try the code below, but it work the same, it only change the coordinates inside the array.
func prevcurrLoc(lat : Double, lng: Double) {
var coordArray : [CLLocationCoordinate2D] = []
let latArray = [lat]
let lngArray = [lng]
if latArray.count == lngArray.count {
for i in 0 ..< latArray.count {
let destination = CLLocationCoordinate2DMake(latArray[i], lngArray[i])
coordArray.append(destination)
print(coordArray)
}
}
}
I hope you understand what I mean. I am very grateful of any help! Thank you for reading.