ios - 分段错误 11 仅适用于 xcode 10 swift 3
问题描述
我将 xcode 9.4 与 swift 3 一起使用,代码运行良好,并且已上线。现在,当我在 xcode 10.1 中运行相同的代码时,我收到很多segmentation fault 11
文件的错误。不知道我该怎么做。我怎样才能将我的 swift 3 转换为 swift 4。因为很多文件我需要更改语法。
更好的是我需要在 xcode 10.1 中使用 swift 3 并且需要解决这个问题segmentation fault 11
。
我在这里遇到的主要错误:
- 在 /Users/Documents/Rough/jeder/JEDE_r/AppDelegate.swift:258:5 处为“application(_:didReceiveRemoteNotification:)”发出 SIL 时
- 而 silgen emitFunction SIL 函数“@$S3WCi11AppDelegateC11application_28didReceiveRemoteNotificationySo13UIApplicationC_SDys11AnyHashableVypGtF”。对于 /Users/Documents/Rough/jeder/JEDE_r/AppDelegate.swift:258:5 处的“应用程序(_:didReceiveRemoteNotification :)”错误:分段错误: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)!
同样在同一个 appdelegate 中,你也做同样的另一种方法。将该行替换为上述行。可能是这个帮助。如果您有任何问题,请告诉我或发布任何其他问题。
推荐阅读
- javascript - 地图:预期元素类型的 mapDiv 但未定义传递 - 谷歌地图
- android - 在 junit 测试中使用 InstantTaskExecutorRule 会导致 java.lang.RuntimeException
- javascript - 如何在笑话测试中模拟外部函数调用
- django - Django 使用 UpdateView 中的发布请求隐藏值定义 URL
- linux - 使用 awk 或 sed 基于公共列组合两个 csv 文件
- node.js - 强制 API 超时时节点 JS 中的套接字挂断错误
- android - 无法在 Android 模拟器上从本地 Flask 服务器接收 200 ok 响应
- java - 我在使用命令提示符执行 java 程序时遇到问题
- javascript - 当我在 JS worker 中导入 WASM 时,“无法解析模块说明符”或“未定义窗口”
- database - 我的应用程序 (MongoDB) 需要哪个 M.. 层?