I have successfully created an array of dictionaries that I thought was a final solution for my question (here: Store CLLocation Manager Values in Device swift) and here is the code I came up with:
func arrayOfDictionaries() {
var offline:[[String:AnyObject]] = []
offline.append(["LATITUDE: ": userLocation.coordinate.latitude, "LONGITUDE: ": userLocation.coordinate.longitude, "SPEED: ": userLocation.speed])
NSUserDefaults().setObject(offline, forKey: "offLine")
if let offLinePositions = NSUserDefaults().arrayForKey("offLine") as? [[String:AnyObject]] {
//print(offLinePositions)
for item in offLinePositions {
print(item["LATITUDE: "]! as! NSNumber) // A, B
print(item["LONGITUDE: "]! as! NSNumber) // 19.99, 4.99
print(item["SPEED: "]! as! NSNumber) // 1, 2
}
}
}
But when I tested the app, I realized that I only have 1 position stored in the array. So my thought is to create another array and insert the values from the first one. How can I do that?