1

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.

enter image description here

enter image description here

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

egor.zhdan
  • 4,555
  • 6
  • 39
  • 53
Josip Bogdan
  • 578
  • 1
  • 5
  • 15

1 Answers1

2

Here is an example of what you should have in Info.plist:

screen

More info here: https://developer.apple.com/library/prerelease/ios/technotes/App-Transport-Security-Technote/

rshev
  • 4,086
  • 1
  • 23
  • 32
  • 1
    An important distinction IMO: This is what you should have in your Info.plist _if you accept the responsibility of loading insecure content over HTTP as opposed to HTTPS_. What you **should** actually do, if it's within your control, is load your content over HTTPS. – Craig Otis Sep 24 '15 at 12:53
  • @CraigOtis Thanks, it's a valuable note! – rshev Sep 24 '15 at 13:16