ios - 当目标为 7.0 时,Xcode 引发 "EXC_BAD_ACCESS code=1"

标签 ios objective-c iphone xcode swift

我将 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 显示给我:

enter image description here

如何调试此类错误?

最佳答案

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/

相关文章:

iphone - iOS-OAuth 实现如何创建框架? (简单的)

ios - 将 Storyboard View 添加为 subview 时发送到已释放实例的消息

ios - 在与 PhysicsBody 碰撞时停止 SKAction

objective-c - iPhone 屏幕截图以供查看

iphone - 是否有关于如何使用 FMDB(sqlite3 包装类)的教程?

ios - 更新iOS应用程序后,是否会删除库/缓存中的文件?

ios - 雪碧包 : how to make newly spawned enemy ships shoot bullets at player?

objective-c - ios拖放 subview 只能工作一次

iphone - iPhone 上的蓝牙低功耗连接间隔

iphone - 如何防止 iphone 调整我网站的字体大小