簡體   English   中英

分段錯誤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錯誤。不確定如何執行此操作。如何將swift 3轉換為swift4。因為許多文件都需要更改語法。

更好的是,我需要在xcode 10.1中使用swift 3並需要解決該segmentation fault 11

我進入這里的主要錯誤:

  1. 在/Users/Documents/Rough/jeder/JEDE_r/AppDelegate.swift:258:5為'application(_:didReceiveRemoteNotification :)'發出SIL時
  2. 而silgen發出了SIL函數“ @ $ S3WCi11AppDelegateC11application_28didReceiveRemoteNotificationySo13UIApplicationC_SDys11AnyHashableVypGtF”。 /Users/Documents/Rough/jeder/JEDE_r/AppDelegate.swift:258:5中的'application(_: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一種方法中,您也一樣。 用上面的那一行代替。 可能是這個幫助。 讓我知道或發布任何其他問題(如果有)。

請嘗試下面的代碼

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)!
            }
        }
  }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM