这个问题已经有了答案:
CFNetwork SSLHandshake failed iOS 9
12个答案
Api Call Error in Xcode 7 / iOS 9 (how to setup App Transport Security in plist)
2个答案
几天前我完成了我的应用程序,安装了xcode 7,这真是个麻烦,我遇到了很多问题,但是大部分问题都解决了,但是现在,当我的应用程序需要连接到Internet时,我得到了一个奇怪的错误
这就是我记录的:
应用传输安全已阻止明文http(http://)资源
加载,因为它是不安全的。临时异常可以通过
你的应用程序的info.plist文件。hempel.temp_不区分大小写_renameagain
使用优化步骤编译的;变量
可能不可用。
swift - 应用传输安全性使Swift 2.0应用崩溃-LMLPHP
swift - 应用传输安全性使Swift 2.0应用崩溃-LMLPHP

let task = session.dataTaskWithRequest(request, completionHandler: {data, response, error -> Void in

            var strData = NSString(data: data!, encoding: NSUTF8StringEncoding)

            do {
                let json = try NSJSONSerialization.JSONObjectWithData(data!, options:NSJSONReadingOptions.MutableContainers ) as? NSDictionary
                if let parseJSON = json {
                   //THIS IS WHERE ERROR IS in other ViewController
                    var success = parseJSON["data"] as! [String: AnyObject]
                    let item = success["hempel_antifoulings"] as! [[String: AnyObject]]
                    for i in item{

                        let product = HempelAntifouling()
                        product.id =  i["id"]
                        product.name = i["name"]
                        product.imageUrl = i["image"]
                        product.subgroup = i["subgroup"]
                        let url = NSURL(string: String(stringInterpolationSegment: product.imageUrl))
                        let data = NSData(contentsOfURL: url!)
                        product.image = UIImage(data: data!)
            // AND THIS IS WHERE THE ERROR POINTS in one of the ViewController
                        self.array.append(product)
                    }

                }else{

                    let jsonStr = NSString(data: data!, encoding: NSUTF8StringEncoding)
                    print("Error could not parse JSON: \(jsonStr)")
                }
            } catch {
                // report error
            }

        })

        task.resume()

    }

p.s.这两行代码在两个viewcontroller中基本相似,但错误是相同的

最佳答案

下面是您在Info.plist中应该拥有的一个示例:
swift - 应用传输安全性使Swift 2.0应用崩溃-LMLPHP
更多信息请点击:https://developer.apple.com/library/prerelease/ios/technotes/App-Transport-Security-Technote/

10-08 05:55
查看更多