hi all,
I have the following method I converting from swift 1.2 to swift 2.0 and had to change the code to use NSURLSession since NSURLConnection is not supported anymore.
following the new code:
func isSessionEnabledForUsername(theUsername: String,completion: ((success:Bool, error:NSError!) -> Void)!) {
let url = NSURL(string: "http:/.....")
let request: NSURLRequest = NSURLRequest(URL: url!)
let config = NSURLSessionConfiguration.defaultSessionConfiguration()
let session = NSURLSession(configuration: config)
let task : NSURLSessionDataTask = session.dataTaskWithRequest(request, completionHandler: {(responseData, response, error) in
let statusCode = self.loadStatusCode(response!)
if statusCode == 403 {
completion(success:false, error:error)
return
} else if (statusCode >= 200 && statusCode < 400 )
{
completion(success:true, error:error)
return
}
}) /
task.resume()
completion(success:true, error: nil)
return
}
the code is not working as expected and for some reason when I try to debug it, I cant get to the line inside the session.dataTaskWithRequest enclosure:
let statusCode = self.loadStatusCode(response!)
the compiler jump me directly to the end of the enclosure: })
any idea what I'm doing wrong?
thanks in advance