Create a variable in swift with dynamic name

前端 未结 4 970
闹比i
闹比i 2020-12-03 21:34

In swift, in a loop managed by an index value that iterates, I want to create a variable which has the variable name that is a concatenation of \"person_\" and the current l

4条回答
  •  感动是毒
    2020-12-03 22:03

    let name = "person_\(index)"

    then add name to a mutable array declared before the loop.

    Something like that?

提交回复
热议问题