I have multiple arrays, The first one contains the names of all the other arrays.
So I retrieve the value of the first array I get the name of my desired array but I don't know how to proceed from there. As swift sees my result as a string, not a variable name. I have recreated my problem below
import UIKit
var str = "Hello, playground"
var traits = ["trait one","trait 2", "trait3"]
var trait3 = ["final Answer 0","final Answer 1","final Answer 2","final Answer 3","final Answer 4"]
var counter = 2
let intermediateV = traits[counter]
print(intermediateV[2])
The error I get is:
'subscript' is unavailable: cannot subscript String with an Int
traits[counter]is"trait3", what isintermediateV[2]aka"trait3"[2]supposed to do? Are you trying to get"final Answer 2"- that is not going to work. Use multi-dimensional arrays instead or (even better) structs and classes, do not create variables with counters as part of their name, that is almost always a bad idea.