Xcode 7 compile error : “Command failed due to signal: Segmentation fault: 11”

前端 未结 25 2356
耶瑟儿~
耶瑟儿~ 2020-12-01 05:37

Yesterday I installed the official Xcode 7 and when I tried to open one of my Swift projects, appeared an alert saying that the new Xcode version wants to update my swift co

25条回答
  •  醉梦人生
    2020-12-01 06:15

    In my case, the cast I had to correct was similar to Murat Yasar answer ( https://stackoverflow.com/a/36867502/512403 ), but mine had two parts to correct. The compiler didn't work with the original fix, so I had to tweak my code still a bit more:

    Bad version:

    let jsonObject: AnyObject? = try NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.AllowFragments)
    

    Good version:

    let jsonObject = try? NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.AllowFragments) as! [String: AnyObject]
    

    Maybe this can help someone new to these quirks of Swift.

提交回复
热议问题