本文介绍了iOS Swift多维度数组 - 编译需要很长时间。我应该改变什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是swift的新人。以前从未在ObjC中编程。
我的iOS应用程序有问题,通过选择器查询非常简单的数组。

I am new at swift. Never programming in ObjC before.I have got a problem with iOS application, very simple-querying arrays via the picker.

我有4个这样的多维数组:

I've got 4 multidimensional arrays like this one:

let Setting = [
    [0,0,0,0,0,0,2230],
    [0,0,0,0,0,2230,2157],
    [0,0,0,0,2230,2230,2085],
    [0,0,0,0,2230,2226,2017],
    [0,0,0,2230,2230,2222,1949],
    [0,0,2230,2230,2230,2218,1880],
    [0,0,2230,2230,2230,2135,1807],
    [0,2230,2230,2230,2230,2052,1735],
    [0,2230,2230,2230,2163,1965,1655],
    [2230,2230,2230,2230,2096,1878,1576],
    [2230,2230,2230,2191,2022,1793,1497],
    [2230,2230,2230,2096,1909,1708,1415],
    [2230,2230,2171,2003,1818,1623,1337],
    [2230,2230,2112,1910,1728,1539,1259],
    [2197,2214,2021,1820,1639,1454,1195],
    [2164,2199,1930,1731,1551,1370,1131],
    [2066,2104,1842,1645,1465,1302,1067],
    [1969,2010,1755,1559,1380,1234,1003],
    [1884,1902,1650,1460,1294,1155,0],
    [1799,1794,1546,1362,1209,1077,0],
    [1726,1665,1429,1259,1110,0,0],
    [1654,1537,1312,1157,1012,0,0],
    [1579,1422,1211,1059,0,0,0],
    [1505,1308,1111,961,0,0,0]
]

如果删除这些,一切都在aplication中完美运行数组(或使用较小的例如2乘2)。当我把它全部放在
的适当位置时,它将一直执行索引。以100%运行我的CPU

Everything works perfectly in the aplication if I remove these arrays (or use smaller e.g. 2 by 2). When I put it all at the proper place it will perform "indexing" all the time. Running my CPU at 100%

当我尝试运行时 - 即使在10小时后它也不会编译。只是坚持编译swift源文件。

When I try to run - it never compils, even after 10 hours. Just stuck at "Compiling swift source files.

我搜索了不同的数据存储,但我需要在确切位置使用这些数字。
数字之间只有很小的核心所以它们不能改成等式。

I searched for different data storage but I need these numbers in exact places. There is only small corelation between numbers so they cannot be changed into equation.

我可以做些什么来编译这个应用程序?

What I can do to compile this aplication?

推荐答案

Swift它很难尝试扣除数组类型。你只需要告诉Swift它是一个Ints数组的数组:

Swift it is having a hard time trying to deduct the array type. You just have to tell Swift it is an Array of Array of Ints:

let setting:[[Int]] = [
    [0,0,0,0,0,0,2230],
    [0,0,0,0,0,2230,2157],
    [0,0,0,0,2230,2230,2085],
    [0,0,0,0,2230,2226,2017],
    [0,0,0,2230,2230,2222,1949],
    [0,0,2230,2230,2230,2218,1880],
    [0,0,2230,2230,2230,2135,1807],
    [0,2230,2230,2230,2230,2052,1735],
    [0,2230,2230,2230,2163,1965,1655],
    [2230,2230,2230,2230,2096,1878,1576],
    [2230,2230,2230,2191,2022,1793,1497],
    [2230,2230,2230,2096,1909,1708,1415],
    [2230,2230,2171,2003,1818,1623,1337],
    [2230,2230,2112,1910,1728,1539,1259],
    [2197,2214,2021,1820,1639,1454,1195],
    [2164,2199,1930,1731,1551,1370,1131],
    [2066,2104,1842,1645,1465,1302,1067],
    [1969,2010,1755,1559,1380,1234,1003],
    [1884,1902,1650,1460,1294,1155,0],
    [1799,1794,1546,1362,1209,1077,0],
    [1726,1665,1429,1259,1110,0,0],
    [1654,1537,1312,1157,1012,0,0],
    [1579,1422,1211,1059,0,0,0],
    [1505,1308,1111,961,0,0,0]
]

注意:按照Swift惯例,你应该用小写字母命名你的vars。

Note: By Swift convention you should name your vars starting with a lowercase letter.

这篇关于iOS Swift多维度数组 - 编译需要很长时间。我应该改变什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 16:26