Learn Courses My Dashboard

Challenge 13 can @State properties somehow be computed variables

So on Challenge 13 of the 14Day Challenge I attempted to put the put the names of the image assets into an array using their string names. I then created a func of the struct ContentView to calculate a random Int, then returning that result to the function.

My next thought was to create a @State property that was a calculated variable defined by calling that func. Therefore, every time I used the index variable in the square brackets of my array, it would be a random Int, therefore resulting in a random image. This was to try to keep from having to create three index @State properties like this.
@State private var index1 = 0
@State private var index2 = 0
@State private var index3 = 0

I wanted to be able to do this.
@State private var index: Int? {

However, as you can imagine, Xcode told me that I am not able to use a Property Wrapper for computed variables.

Is there a way I can achieve my goal that I just don’t know about?

If you have any thoughts, tips, tricks, or wisdom, thank you!

i don’t understand what you are trying to achieve and why do you need 3 indexes?