How can I store huge constant arrays in swift without the compiler lagging? I have made 4 arrays with about a hundred items each, and my compiler takes 2 minutes to compile. Any help would be appriceated.
如何在没有编译器滞后的情况下在swift中存储巨大的常量数组?我已经制作了4个数组,每个数组大约有一百个,我的编译器需要2分钟才能编译。任何帮助都会被评估。
Edit: I do not want to use core data.
编辑:我不想使用核心数据。
2 个解决方案
#1
2
You can use SQLite database or you can store in text file.
您可以使用SQLite数据库,也可以存储在文本文件中。
#2
1
If you are initialising the array in the same line as declaration, it will slow down the compiler. The easiest way around it is to declare your array and then add objects to it. Something along the lines of
如果要在与声明相同的行中初始化数组,则会降低编译器的速度。最简单的方法是声明您的数组,然后向其中添加对象。有点像
var arr = Array<String>()
arr.append("First Entry")
arr.append("Second Entry")
arr.append("Third Entry")
and so on.
等等。
#1
2
You can use SQLite database or you can store in text file.
您可以使用SQLite数据库,也可以存储在文本文件中。
#2
1
If you are initialising the array in the same line as declaration, it will slow down the compiler. The easiest way around it is to declare your array and then add objects to it. Something along the lines of
如果要在与声明相同的行中初始化数组,则会降低编译器的速度。最简单的方法是声明您的数组,然后向其中添加对象。有点像
var arr = Array<String>()
arr.append("First Entry")
arr.append("Second Entry")
arr.append("Third Entry")
and so on.
等等。