I'm asking this out of curiosity to understand Swift.
I'm trying to update objects in an array situated in another class.
I have two cases (the other one works, and other one doesn't)
- Working solution:
Data.tripModels[0].title = "lol"
- Not working:
var trip = Data.tripModels[0]
trip.title = "lol"
To help you understand:
Data = the other class
tripModels = the array in Data class, holding the objects
title = a property of tripModel in tripModels array
Why is the 2. not working? :(
struct?structs are value types, so you're updating a copy.