I've always struggled with arrays; I´m trying to save some arrays into user defaults. my arrays are String, Double and UIImageView type. I declared them like:
var nameHospital = [String]()
var distanceBetweenLocations = [Double]()
var images = [UIImage]() // <-- Haven't tried with this yet
and I try to save them in UserDefaults like this...
UserDefaults.standard.set(nameHospital, forKey: "name")
And call theme like so
UserDefaults.standard.object(forKey: "name")
Then when I want to print them to see if it worked, it only prints one value (last value of the For Cycle) then I set my print inside the for and as I was expecting, it printed the value and then replaced it for the next value and so on.
What am I doing wrong? How can I call each value separately for further functions? And How can I do this but with my UIImage array? Thank you for your answers.