我将 Xcode 6.3 beta4 与 SDK 6.4 和 Target 7.1 一起使用。
在 iOS 7.1 模拟器或设备上运行如下简单的一行会引发错误:
let alert = UIAlertController(title: "title", message: "message", preferredStyle: .Alert)
错误是:
EXC_BAD_ACCESS code=1
当我在 iOS 8.4 模拟器中运行时,不会发生错误。
好像是SDK版本不同导致的冲突。
如何防止在 iOS 版本 7.x 的目标上运行时出现 EXC_BAD_ACCESS code=1
错误?
编辑:Xcode 显示给我:
如何调试此类错误?
最佳答案
iOS7 中的 UIAlertView
已被 iOS8 中的 UIAlertController
取代。
我建议您按照以下步骤解决兼容性问题
if objc_getClass("UIAlertController") != nil {
println("UIAlertController can be instantiated")
//make and use a UIAlertController
}
else {
println("UIAlertController can NOT be instantiated")
//make and use a UIAlertView
}
关于ios - 当目标为 7.0 时,Xcode 引发 "EXC_BAD_ACCESS code=1",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29794768/