我使用了 xcode 9.4 和 swift 3,代码工作正常并且已经上线。现在,当我在 xcode 10.1 中运行相同的代码时,我在许多文件中收到许多 segmentation failure 11
错误。不知道如何才能做到这一点。以及如何将我的 swift 3 转换为 swift 4。Bec我需要更改许多文件的语法。
更好的是,我需要在 xcode 10.1 中使用 swift 3,并且需要解决段错误 11
。
我在这里遇到的主要错误:
- While emitting SIL for 'application(_:didReceiveRemoteNotification:)' at /Users/Documents/Rough/jeder/JEDE_r/AppDelegate.swift:258:5
- 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/