Hello i have a small a problem with the code below, Xcode print this error:
ERROR: json error: Error Domain=NSCocoaErrorDomain Code=3840 "No value." UserInfo={NSDebugDescription=No value.}
SWIFT CODE:
let yourUrl=“mylink.php”let URL = NSURL(string:yourUrl)let request:NSMutableURLRequest = NSMutableURLRequest(URL: URL!)let boundaryConstant = "V2ymHFg03esomerandomstuffhbqgZCaKO6jy";let contentType = "multipart/form-data; boundary=" + boundaryConstant NSURLProtocol.setProperty(contentType, forKey: "Content-Type", inRequest: request)let dataString = "Email=\(Email.text)&Password=\(Password.text)"request.HTTPMethod = "POST"request.HTTPBody = (dataString as NSString).dataUsingEncoding(NSUTF8StringEncoding)let task = NSURLSession.sharedSession().dataTaskWithRequest(request, completionHandler: { (data, response, error) -> Void in / / do{let str = try NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.AllowFragments) as! [String:AnyObject]print(str)} catch {print("json error: \(error)")} })task.resume()PHP CODE:(mylink.php)
<?php header("Content-Type: application/json"); $email = $_POST["Email"]; $password = $_POST["Password"]; $stat=“myvalue”; return json_encode($stat); ?>