This is the part of my code that crashes:
let bodyData = "username=" + username + "&password=" + password
let URL: NSURL = NSURL(string: "URL OF A PHP FILE")!
let request:NSMutableURLRequest = NSMutableURLRequest(URL:URL)
request.HTTPMethod = "POST"
request.HTTPBody = bodyData.dataUsingEncoding(NSUTF8StringEncoding);
NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.mainQueue()) // Crashes here !
{
(response, data, error) in
var output = NSString(data: data, encoding: NSUTF8StringEncoding)
[Rest of the code]
}
the error is:
fatal error: unexpectedly found nil while unwrapping an Optional value
I thinks it's NSURLConnection.sendAsynchronousRequest that makes my app crashes cause i've debugged my app and it crashes there
This is the value of request:
<NSMutableURLRequest: 0x14d55b70> { URL: [URL OF PHP FILE] }
And i know that the data variable is not nil