解析LogIn和SignUp Func SWIFT

时间:2015-07-18 20:52:16

标签: ios xcode swift parse-platform

所以我遇到的问题是我正在观看教程,当我在其下面的代码行中放入它自动使它成为一个函数。对我来说,当我输入它时,我得到的是

logInViewController(logInController: PFLogInViewController!, shouldBeginLogInWithUsername: String!, password: String!)

这不是一个功能。所以我试着通过在开头添加func并在末尾添加{}来尝试使它成为一个函数(见下文)

func logInViewController(logInController: PFLogInViewController!, shouldBeginLogInWithUsername: String!, password: String!){

    }

当我添加下一个(看下面)

时,一切正常
func logInViewController(logInController: PFLogInViewController!, didLogInUser: PFUser!){

    }

我收到错误"定义与先前值的冲突",我能够只更改函数的名称,一切都会好吗?因为在视频中,我看到他们不需要更改名称。

那么如何在没有错误的情况下让它工作呢。

以下是所有代码

import UIKit
import Parse
import ParseUI



class homeViewController: UIViewController, PFLogInViewControllerDelegate, PFSignUpViewControllerDelegate {







//These are all Buttons--------------
@IBAction func emailB(sender: UIButton) {
    println("Email View : Pressed : Working")

}


@IBAction func EstimatorB(sender: UIButton) {
    println("Estimator View : Pressed : Working")
    let viewEstimator: AnyObject! = self.storyboard!.instantiateViewControllerWithIdentifier("EstimatorScreen")
    viewEstimator
}
//====================================

//Login Screen Pop-up-----------------
override func viewDidAppear(animated: Bool) {
    super.viewDidAppear(animated)


    if (PFUser.currentUser() == nil){

        var LogInViewController : PFLogInViewController! = PFLogInViewController()


        LogInViewController.delegate = self

        var signUpViewController: PFSignUpViewController! = PFSignUpViewController()

        signUpViewController.delegate = self

        LogInViewController.signUpController = signUpViewController

        self.presentViewController(LogInViewController, animated: true, completion: nil)


    }
//=======================================






//To go to another screen
//let viewHome = self.storyboard?.instantiateViewControllerWithIdentifier("HomeScreen")

// IGNOR THIS CODE-------=======================
 func viewDidLoad() {
    super.viewDidLoad()

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

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


//MARK : Login 
    func logInViewController(logInController: PFLogInViewController!, shouldBeginLogInWithUsername: String!, password: String!){

    }

     func logInViewController(logInController: PFLogInViewController!, didLogInUser: PFUser!){

    }

     func logInViewController(logInController: PFLogInViewController, didFailToLogInWithError: NSError!){

    }


//MArK : SignUp

     func signUpViewController(signUpController: PFSignUpViewController, shouldBeginSignUp: [NSObject : AnyObject]){

    }

     func signUpViewController(signUpController: PFSignUpViewController, didSignUpUser: PFUser){

    }

    func  signUpViewController(signUpController: PFSignUpViewController, didFailToSignUpWithError: NSError?){

    }







}

}

2 个答案:

答案 0 :(得分:0)

如果你想在没有头脑疼痛的情况下为你做登录/注册...这里有一个很棒的教程,可以逐步完成自己的自定义教程。它非常简单。 我最终没有使用他们的,因为它一直给我的所有错误。 https://medium.com/swift-programming/ios-swift-parse-com-part-3-sign-up-sign-in-sign-out-security-349adc94ef0e

答案 1 :(得分:0)

我的swift文件设置与你的一样,但是我建议你去自定义登录的路线,因为A)你有更多的控制权和B)它非常简单,并且不需要花费太多时间。另外我假设你是一个解析初学者,我建议的方法会让你更好地理解登录/注册的工作原理。