arrays - 数组名称被描述为字符串

标签 arrays swift string

我有多个阵列,我想选择一个作为我的主阵列。我希望将主数组描述为字符串。如何使用我的 StationID 字符串和 DirectionID 字符串命名新数组?

    let Farbhof1 = ["hi","some","Strings"]

    var StationID = "Farbhof"
    var DirectionID = "1"

DestViewController.TableViewArray = "\(StationID)\(DirectionID)"

最佳答案

你不能在 Swift 中做到这一点。变量名需要在编译时知道,不能在运行时计算。

关于arrays - 数组名称被描述为字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45784498/

相关文章:

c - 在 C 中声明我的 int 数组

ios - 我们可以在 swift playgrounds 中使用 AVAudiorecorder 吗?

python - 使用python将一个字符串拆分成它的句子

c - 字符串文字是常量吗?

c - 通过指针算法迭代结构数组

arrays - 我可以使用 -v 将数组传递给 awk 吗?

javascript - 如何验证数组(矩阵)格式?

ios - 如何在 TableView 中显示 APAddressBook 的联系人

ios - 将数据从第一个 VC 传递到第三个 (Swift)

Javascript 替换功能不会删除引号