gpt4 book ai didi

ios - 在 iphone 上查看文件时 Swift EXC_BREAKPOINT。适用于一部 iPhone 但不适用于其他 iPhone

转载 作者:搜寻专家 更新时间:2023-11-01 06:24:35 26 4
gpt4 key购买 nike

我在使用 Swift 时遇到了一个奇怪的错误,我不知道为什么以及如何解决它

代码:

var bool = NSFileManager.defaultManager().fileExistsAtPath(NSBundle.mainBundle().pathForResource(fileToOpen, ofType: "txt", inDirectory: "levels"))
println("Bool : \(bool)")
if(bool){
let pathToFile = NSBundle.mainBundle().pathForResource(fileToOpen, ofType: "txt", inDirectory: "levels")
let fileInfo = String.stringWithContentsOfFile(pathToFile, encoding: NSUTF8StringEncoding, error: error)
var textArray = [String]()
println(fileInfo)

错误:

EXC_BREAKPOINT(code=EXC_ARM_BREAKPOINT, subcode=0xe7ffdefe)

问题:

此代码在我的 iPhone 5S 上运行良好,但当我在 iPhone 4S 上尝试此代码时,它在第一行崩溃 (var bool = NSFileManager.defaultMan...)我知道确实存在一个文件,因为 bool 返回 true 并且在我的 iPhone 5S 上代码有效,我也知道即使它说 var bool 行有一个异常该行后面的代码段仍在执行,例如 println(fileInfo) 仍在执行。所以我假设即使代码的第一行确实出现异常,错误也不存在吗?任何人都知道如何解决这个问题?提前致谢!

更多信息:

使用 xcode 6-beta 3iphone 5s 是 7.1.2iphone 4s 是 7.1

最佳答案

问题解决了。在我使用 arc4random % number 的代码中,问题更进一步我将其更改为 arc4random_uniform(UInt32(number)) 并且错误消失了

关于ios - 在 iphone 上查看文件时 Swift EXC_BREAKPOINT。适用于一部 iPhone 但不适用于其他 iPhone,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24814351/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com