I am very new to Swift, so excuse me if this is a dumb question.
I have a JSON X array of objects, which I load into my app and pass around views (I have a defined struct for it). Now in another view I have a new struct, which looks like this:
struct Pin: Identifiable {
var name: String
let id = UUID()
}
and later make an array like so:
@State private var pins: [Pin] = []
How can I make this array to contain Pin objects, but made from my existing X array. What I mean that each new Pin inside pins array would have the values of Pin(name: X.name[0] and so on for each element in my X array.
So my final pins array should look something like:
[Pin(name: x.name[0]...), Pin(name: x.name[1]...), Pin(name: x.name[2]...)...]
Xarray? And what about theimagein the new array?Xarray is an array of objects, each with aname,descriptionand couple other fields I don't need for this particular view. You can ignore the image, I was gonna have it but ultimately decided not to, will remove it from the code sample :)