有没有一种方法可以从value(array)定义变量名? 我需要它来自动创建数组,但我不想手动输入类型名称,而是从数组中选择它。
dataEmail = ["1", "POS101582781", "2018.10.26 10:02", "Buy", "1", "VMID", "29.435", "", "", "", "30.42", "0.99", "30.42\n2", "POS104121282", "2018.12.10 10:00", "Buy", "1", "PSN", "1940", "", "", "", "2440", "5", "24.4\n3", "POS101582480", "2018.10.26 10:00", "Buy", "2", "HL", "1796.5", "", "", "", "1730", "-1.33", "34.6\n4", "POS101582499", "2018.10.26 10:00", "Buy", "8", "INVP", "473.6", "", "", "", "493.4", "1.58", "39.47\n5", "POS102186690", "2018.11.06 10:00", "Buy", "40", "VOD", "153.63", "", "", "", "134.38", "-7.7", "53.75\n6", "POS105530053", "2019.01.04 10:00", "Buy", "5", "MKS", "253.4", "", "", "", "272.5", "0.96", "13.63\n7", "POS102224924", "2018.11.06 17:52", "Buy", "14", "EVR", "488.15", "", "", "", "563.4", "10.54", "78.88\n8", "POS102087914", "2018.11.02 17:32", "Buy", "59", "DC", "164.112", "", "", "", "133.2", "-18.24", "78.59\n9", "POS101582520", "2018.10.26 10:00", "Buy", "20", "BT", "241.4", "", "", "", "214.9", "-5.3", "42.98\n10", "POS101582491", "2018.10.26 10:00", "Buy", "101", "LLOY", "55.5975", "", "", "", "63.58", "8.06", "64.22\n11", "POS101582545", "2018.10.26 10:00", "Buy", "26", "AV", "413.662", "", "", "", "423.2", "2.48", "110.03\n12", "POS104121258", "2018.12.10 10:00", "Buy", "10", "PTEC", "389.6", "", "", "", "420.9", "3.13", "42.09\n13", "POS104962193", "2018.12.24 10:40", "Buy", "11", "RMG", "286.009", "", "", "", "283.4", "-0.29", "31.17\n14", "POS105487268", "2019.01.03 18:29", "Buy", "22", "CREI", "115.0909", "", "", "", "113.6", "-0.33", "24.99\n15", "POS108707475", "2019.02.14 10:00", "Buy", "4", "IMB", "2640", "", "", "", "2508.5", "-5.26", "100.34\n16", "POS102853078", "2018.11.16 11:45", "Buy", "3", "HMSO", "418.067", "", "", "", "377.9", "-1.21", "11.34\n17", "POS103378446", "2018.11.27 10:12", "Buy", "60", "CNCT", "37.3667", "", "", "", "38.65", "0.77", "23.19"]
let arrayName = ["VMID", "PSN", "HL", "INVP", "VOD", "MKS", "EVR", "DC", "BT", "LLOY", "AV", "PTEC", "RMG", "CREI", "IMB", "HMSO", "CNCT"]
func createStockSet (){
var indexNumber = 1
for n in 0...16 {
var arrayName[0] = StockClass(transactionName: dataEmail[indexNumber], date: dataEmail[indexNumber+1], type: dataEmail[indexNumber+2], amount: dataEmail[indexNumber+3], stockTinker: dataEmail[indexNumber+4], boughtPrice: dataEmail [indexNumber+5], nowPrice: dataEmail[indexNumber+6], floatingResult: dataEmail[indexNumber+9], margin: dataEmail[indexNumber+10])
indexNumber + 3
}}