分段错误 11 仅适用于 xcode 10 swift 3
Segmentation fault 11 only for xcode 10 swift 3
我将 xcode 9.4 与 swift 3 一起使用,代码运行良好,并且已上线。现在,当我 运行 我在 xcode 10.1 中使用相同的代码时,我收到许多 segmentation fault 11
错误 files.Not 确定我该怎么做 that.And 我该如何转换我的swift 3 到 swift 4。因为很多文件我需要更改语法。
最好我需要在 xcode 10.1 中使用 swift 3 并且需要解决 segmentation fault 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 fault 11
错误,近 22 个文件显示该错误。
请提供任何帮助!!
更改此行:
let person:NSDictionary = (tempDict.value(forKey: "custom") as? NSDictionary!)!
到
let person:NSDictionary = (tempDict.value(forKey: "custom") as? NSDictionary)!
同样在同一个应用程序中委托另一种方法,你也这样做。用上面的那一行替换那一行。可能是这个帮助。如果您有任何其他问题,请告诉我或post。
请尝试以下代码
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 = UIAlertController(title: "alertView", message: (tempDict.value(forKey: "alert") as? String)!, preferredStyle: .alert)
let ok = UIAlertAction(title: "OK", style: .default, handler: nil)
alert.addAction(ok)
//alert.show()
self.window?.rootViewController?.present(alert, animated: true, completion: nil)
let _:NSDictionary = (tempDict.value(forKey: "custom") as? NSDictionary)!
}
}
}
我将 xcode 9.4 与 swift 3 一起使用,代码运行良好,并且已上线。现在,当我 运行 我在 xcode 10.1 中使用相同的代码时,我收到许多 segmentation fault 11
错误 files.Not 确定我该怎么做 that.And 我该如何转换我的swift 3 到 swift 4。因为很多文件我需要更改语法。
最好我需要在 xcode 10.1 中使用 swift 3 并且需要解决 segmentation fault 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 fault 11
错误,近 22 个文件显示该错误。
请提供任何帮助!!
更改此行:
let person:NSDictionary = (tempDict.value(forKey: "custom") as? NSDictionary!)!
到
let person:NSDictionary = (tempDict.value(forKey: "custom") as? NSDictionary)!
同样在同一个应用程序中委托另一种方法,你也这样做。用上面的那一行替换那一行。可能是这个帮助。如果您有任何其他问题,请告诉我或post。
请尝试以下代码
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 = UIAlertController(title: "alertView", message: (tempDict.value(forKey: "alert") as? String)!, preferredStyle: .alert)
let ok = UIAlertAction(title: "OK", style: .default, handler: nil)
alert.addAction(ok)
//alert.show()
self.window?.rootViewController?.present(alert, animated: true, completion: nil)
let _:NSDictionary = (tempDict.value(forKey: "custom") as? NSDictionary)!
}
}
}