当我在level.txts中进行更改时,为什么模拟器崩溃?

时间:2019-04-29 11:16:39

标签: swift xcode

  

我正在制作文字捕捉应用,模拟器运行正常,直到我更改为止   在level.txt文件中。

     

当我更改答案或只是提示时,模拟器崩溃了   立即。

if let levelFileURL = Bundle.main.url(forResource: "level\(level)", withExtension: "txt") {
        if let levelContents = try? String(contentsOf: levelFileURL) {
            var lines = levelContents.components(separatedBy: "\n")
            lines.shuffle()

            for (index, line) in lines.enumerated() {
                let parts = line.components(separatedBy: ": ")
                let answer = parts[0]
                let clue = parts[1]

                clueString += "\(index + 1). \(clue)\n"

                let solutionWord = answer.replacingOccurrences(of: "|", with: "")
                solutionsString += "\(solutionWord.count) letters\n"
                solutions.append(solutionWord)

                let bits = answer.components(separatedBy: "|")
                letterBits += bits
            }
        }
    }
  

更改后,我得到以下错误:线程1:致命错误:索引超出   范围和聊天记录中,“对此不支持MGIsDeviceOneOfType   平台。''

0 个答案:

没有答案