当我运行我的代码我得到这个错误,我不知道为什么.
错误域= NSCocoaErrorDomain代码= 3840"没有值." UserInfo = {NSDebugDescription =无值.}
我在互联网上找了它,但我找不到东西.
这是我的代码:
let myUrl = NSURL(string: "http://foodhelper.club/registerUser.php");
let request = NSMutableURLRequest(URL:myUrl!);
request.HTTPMethod = "POST";
let postString = "userEmail=\(userEmail!)&userFirstName=\(userFirstName!)&userLastName=\(userLastName!)&userPassword=\(userPassword!)";
request.HTTPBody = postString.dataUsingEncoding(NSUTF8StringEncoding);
NSURLSession.sharedSession().dataTaskWithRequest(request, completionHandler: { (data:NSData?, response:NSURLResponse?, error:NSError?) -> Void in
dispatch_async(dispatch_get_main_queue())
{
if error != nil {
self.alertMessage(error!.localizedDescription)
print("fail")
return
}
do {
let json = try NSJSONSerialization.JSONObjectWithData(data!, options: .MutableContainers) as? NSDictionary
print ("1")
if let parseJSON = json {
let userId = parseJSON["userId"] as? String
print ("2")
if( userId != nil) …
Run Code Online (Sandbox Code Playgroud)