I completed my app few days ago, and installed Xcode 7, and it was a pain in the ass, I had lot of problem, but managed to fix most of them, but now, when my app needs to connect to internet I get this strange error This is what i get logged:
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()
}
P.S. These lines of code are mostly similar in both ViewControllers, but errors are same
Here is an example of what you should have in Info.plist
:
More info here: https://developer.apple.com/library/prerelease/ios/technotes/App-Transport-Security-Technote/