ios - 段错误 11 仅适用于 xcode 10 swift 3

标签 ios swift iphone swift3 xcode10

我使用了 xcode 9.4 和 swift 3,代码工作正常并且已经上线。现在,当我在 xcode 10.1 中运行相同的代码时,我在许多文件中收到许多 segmentation failure 11 错误。不知道如何才能做到这一点。以及如何将我的 swift 3 转换为 swift 4。Bec我需要更改许多文件的语法。

更好的是,我需要在 xcode 10.1 中使用 swift 3,并且需要解决段错误 11

我在这里遇到的主要错误:

  1. While emitting SIL for 'application(_:didReceiveRemoteNotification:)' at /Users/Documents/Rough/jeder/JEDE_r/AppDelegate.swift:258:5
  2. While silgen emitFunction SIL function "@$S3WCi11AppDelegateC11application_28didReceiveRemoteNotificationySo13UIApplicationC_SDys11AnyHashableVypGtF". for 'application(_:didReceiveRemoteNotification:)' at /Users/Documents/Rough/jeder/JEDE_r/AppDelegate.swift:258:5 error: Segmentation fault: 11

我的代码:

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) 
{
    if application.applicationState == .inactive || application.applicationState == .background {
        //opened from a push notification when the app was on background
    }
    else
    {
        if application.applicationState == .active
        {
            let myuserinfo = userInfo as NSDictionary
            print(myuserinfo)

            let tempDict:NSDictionary = (myuserinfo.value(forKey: "aps") as? NSDictionary)!
            let alert = UIAlertView(title: "alertView", message: (tempDict.value(forKey: "alert") as? String)!, delegate: nil, cancelButtonTitle:"Cancel", otherButtonTitles: "Done", "Delete")
            alert.show()
            let person:NSDictionary = (tempDict.value(forKey: "custom") as? NSDictionary!)!
        }
    }
}

这里有什么问题。我怎样才能解决所有 segmentation failure 11 错误,近 22 个文件显示该错误。

请帮忙!!

最佳答案

改变这一行:

let person:NSDictionary = (tempDict.value(forKey: "custom") as? NSDictionary!)!

let person:NSDictionary = (tempDict.value(forKey: "custom") as? NSDictionary)!

还在同一个应用程序中委托(delegate)另一种方法,您也这样做。将这一行替换为上面的一行。可能是这个帮助。如果您有任何其他问题,请告诉我或发布任何其他问题。

关于ios - 段错误 11 仅适用于 xcode 10 swift 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55136310/

相关文章:

ios - 使用 NSKeyedArchiver 归档和取消归档时是否保留引用?

iphone - 分享我的 iPhone 应用程序进行测试

iOS Storyboard和注入(inject)属性

ios - `UITabBarController` 切换标签时去除黑色背景

ios - swift 3 : Tab Bar Controller Image Size Issue

iphone - 如何在uitableview中添加搜索栏?

iphone - 转换字符串值数组以用作公式

ios - 与@nonescaping 相比,@escpaing 闭包在内存中的存储方式有何不同

ios - 动态改变TableView Cell高度

objective-c - 没有iPhone应用程序的调试信息