我正在尝试从我的应用中完成用户注册。
使用Alamofire我试图通过我的php文件/服务器将我的iOS应用程序连接到我的数据库 - 但我收到此错误消息:
FAILURE:responseSerializationFailed(Alamofire.AFError.ResponseSerializationFailureReason.jsonSerializationFailed(错误域= NSCocoaErrorDomain代码= 3840"字符0周围的值无效。" UserInfo = {NSDebugDescription =字符0周围的值无效}}))
这是我的代码 -
import Alamofire
import UIKit
class SignUpComplete: UIViewController {
let URL_USER_REGISTER = "https:/mooverdata345.co.uk/registerIPHONE.php";
@IBOutlet var Email: UITextField!
@IBOutlet var Password: UITextField!
@IBOutlet var Username: UITextField!
@IBOutlet var Firstname: UITextField!
@IBOutlet var Surname: UITextField!
@IBOutlet var HouseNo: UITextField!
@IBOutlet var Postcode: UITextField!
@IBOutlet var labelMessage: UILabel!
@IBAction func submit(_ sender: UIButton) {
let parameters: Parameters=[
"Email":Email.text!,
"Password":Password.text!,
"Firstname":Firstname.text!,
"Surname":Surname.text!,
"HouseNo":HouseNo.text!,
"Postcode":Postcode.text!
]
Alamofire.request(URL_USER_REGISTER, method: .post, parameters: parameters).responseJSON
{
response in
//printing response
print(response)
//getting the json value from the server
if let result = response.result.value {
//converting it as NSDictionary
let jsonData = result as! NSDictionary
//displaying the message in label
self.labelMessage.text = jsonData.value(forKey: "message") as! String?
}
}
}
}
我认为这可能与JSON有关。 SQL查询正在运行,因此后端的东西是可以的。我的队友的Android应用程序正常连接。