我使用heroku进行了简单的登录,但是我遇到了常见错误
the data couldn't be read because it isn't in the correct format
我的输入均不为空,请参见以下打印输出:
输入:
User field = "testuser"
password field = "1"
email field = "testemail@gmail.com"
fullname field = "me tester"
这是我的代码:
@IBAction func signUpBtn_click(_ sender: AnyObject) {
print("sign up pressed")
let user = PFUser()
user.username = usernameTxt.text?.lowercased()
user.email = emailTxt.text?.lowercased()
user.password = passwordTxt.text
user["fullname"] = fullnameTxt.text?.lowercased()
print("user-->", user)
user.signUpInBackground { (success, error) -> Void in
if success {
print("Logged in")
UserDefaults.standard.set(user.username, forKey: "username")
UserDefaults.standard.synchronize()
let appDelegate : AppDelegate = UIApplication.shared.delegate as! AppDelegate
appDelegate.login()
} else {
let alert = UIAlertController(title: "Error", message: error!.localizedDescription, preferredStyle: UIAlertController.Style.alert)
let ok = UIAlertAction(title: "OK", style: UIAlertAction.Style.cancel, handler: nil)
alert.addAction(ok)
self.present(alert, animated: true, completion: nil)
}
}
}
打印出=
user--> <PFUser: 0x600002225000, objectId: new, localId: (null)> {
email = "testemail@gmail.com";
fullname = "me tester";
password = 1;
username = testuser;
}
有人可以帮助解决这个问题吗?
谢谢