<分区>
我几天前完成了我的应用程序,并安装了 Xcode 7,这让我很头疼,我遇到了很多问题,但设法解决了大部分问题,但是现在,当我的应用程序需要连接到互联网时我收到这个奇怪的错误 这是我记录的内容:
App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file. Hempel.temp_caseinsensitive_renameAgain was compiled with optimization - stepping may behave oddly; variables may not be available.
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()
}
附言这些代码行在两个 ViewControllers 中大部分相似,但错误是相同的