如何使用Swift将注册页面添加到我的Parse应用程序中?

时间:2015-08-21 15:48:21

标签: ios swift parse-platform

任何人都知道如何让用户在Swift Xcode 6.4中使用解析进行注册? 我已经搜索了所有内容,无法找到有效的内容。

我试过这段代码,但它没有用。

它说:

  

使用未解析的标识符PFUser

import UIKit

class SignupViewController: UIViewController {

@IBOutlet var usernameTextField: UITextField!
@IBOutlet var passwordTextField: UITextField!
@IBOutlet var emailTextField: UITextField!
@IBOutlet var messageLabel: UILabel!

@IBAction func loginVerifyButton(sender: AnyObject) {
    var usrEntered = usernameTextField.text
    var pwdEntered = passwordTextField.text
    var emlEntered = emailTextField.text
    if usrEntered != "" && pwdEntered != "" && emlEntered != "" {
        // If not empty then yay, do something
    } else {
        WrongInfo()
    }
}
func userSignUp() {
    var user = PFUser()
    user.username = usrEntered
    user.password = pwdEntered
    user.email = emlEntered
}



override func viewDidLoad() {
    super.viewDidLoad()

    // Do any additional setup after loading the view.
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}


/*
// MARK: - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    // Get the new view controller using segue.destinationViewController.
    // Pass the selected object to the new view controller.
}
*/

func WrongInfo(){
    var WrongInfo:UIAlertView = UIAlertView(title: "ALL FEILDS REQUIRED", message: "Please use all feilds!", delegate: self, cancelButtonTitle: "ok")
}
}

2 个答案:

答案 0 :(得分:0)

您必须创建自己的视图,然后根据用户的当前状态实现/ segue用户。如果他们单击您的注册按钮,则将其转换为自定义视图,然后相应地执行操作。您可以使用与您在问题中提供的功能类似的功能对其进行签名:

func myMethod() {
var user = PFUser()
user.username = "myUsername"
user.password = "myPassword"
user.email = "email@example.com"
// other fields can be set just like with PFObject
user["phone"] = "415-392-0202"

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.
  }
}

你基本上可以使用你已经拥有的相同视图,因为你的字段是相同的,但根据他们选择的按钮调用不同的方法。

答案 1 :(得分:0)

你需要在Appdelegate.swift文件中导入Parse!如果仍然得到相同的错误导入注册视图控制器Parse

相关问题