我沒有收到任何錯誤,應用程序生成良好,但是當我檢查解析時,沒有添加新用戶。這裏是代碼:iOS Swift +解析用戶註冊不傳遞任何數據來解析
import UIKit
import Parse
class ViewController: UIViewController {
@IBOutlet var passwordTextField: UITextField!
@IBOutlet var emailTextField: UITextField!
//@IBOutlet var messageLabel: UILabel!
@IBAction func loginVerifyButton(sender: AnyObject) {
var pwdEntered = passwordTextField.text
var emlEntered = emailTextField.text
if pwdEntered != "" && emlEntered != "" {
// If not empty then yay, do something
func userSignUp() {
var user = PFUser()
user.email = emlEntered
user.password = pwdEntered
user.signUpInBackgroundWithBlock {
(succeeded: Bool, error: NSError?) -> Void in
if let error = error {
let errorString = error.userInfo?["error"] as? NSString
// Show the errorString somewhere and let the user try again.
} else {
// Hooray! Let them use the app now.
}
}
}
}else {
//self.messageLabel.text = "All Fields Required"
}
你嘗試添加用戶名PFUser所以,從這個改變? – ridvankucuk
如果您在「if let error = error」行設置了Xcode斷點,那麼當您按下loginVerify按鈕時該命令會被觸發嗎?此外,'signUpInBackgroundWithBlock'用於創建新帳戶,但您的函數名稱爲'loginVerifyButton'。 [有一個單獨的PFUser登錄方法](https://parse.com/docs/osx/api/Classes/PFUser.html#//api/name/logInWithUsername:password:error :),你究竟在嘗試去做? –
這是在iOS9上嗎? App Transport Security在最近的幾個beta中啓用,因此您需要在info.plist中添加解析異常。這是一篇很好的文章,可以在運行iOS 9時進行設置:http://ste.vn/2015/06/10/configuring-app-transport-security-ios-9-osx-10-11/ –