Swift数组大小限制和Xcode编译限制 [英] Swift Array size limit and Xcode compile limits

查看:108
本文介绍了Swift数组大小限制和Xcode编译限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经提取了OSX英语词典,并希望在我的Swift iPhone应用程序中使用它.它大约有236,000个单词,我已经添加到一个快速的字符串数组中.

I have extracted OSX English language dictionary and want to use it in my Swift iPhone app. It has about 236,000 words which I have added to a swift string array.

当我尝试运行构建时,需要花费很长时间进行编译,然后抛出 Segmentation Fault 11

When I try to run the build, it takes a long time to compile and then throws Segmentation Fault 11

这是因为数组太大了吗?

Is this because the array is too big?

我要在项目中添加英语词典的正确路径吗?

Am I going the correct path trying to add english dictionary in my project?

推荐答案

我能够通过将实际的词典文本文件添加到我的xcode项目中来解决此问题.然后利用以下代码将文件中的单词填充到数组中.速度非常快.

I was able to solve this problem by adding the actual dictionary text file into my xcode project. then utilize below code to fill words from the file to an array. it was pretty fast.

let path = NSBundle.mainBundle().pathForResource("dict2", ofType: "txt")
let dico = String(contentsOfFile: path!, encoding: NSUTF8StringEncoding, error: nil)
let dict = dico!.componentsSeparatedByString("\n")

希望它对某人有帮助.

这篇关于Swift数组大小限制和Xcode编译限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆