在构建app时无法与Parse交互

时间:2015-05-25 14:57:54

标签: ios parse-platform

我正在使用xCode,我正在尝试创建一个用户注册并使用Parse作为我的后端登录。我创建了一个代码,当我尝试登录或注册时,控制台应该打印一行代码。但没有打印。请帮忙。以下是我的代码

func authenticate()
    {
        var email = self.emailTextField?.text
        var password = self.passwordTextField?.text

        if (email?.isEmpty == true || password?.isEmpty == true || email?.isEmailAddress() == false) //is this an email adress
        {
            // alert the user
            return
        }

        if authMode == .SignIn
        {
            self.signIn(email!, password: password!)
        }

        else
        {
            self.signUp(email!, password: password!)
        }
    }

    func signIn(email: String?, password: String?)
    {

        PFUser.logInWithUsernameInBackground(email!, password: password!) {
            (user: PFUser?, error: NSError?) -> Void in

            if ((user) != nil)
            {
                println("sign in success")
            }

            else
            {
                println("sign in failure! (alert the user)")
            }
        }

    }

    func signUp(email: String?, password: String?)
    {
        var user = PFUser()
        user.username = email
        user.email = email
        user.password = password

        user.signUpInBackgroundWithBlock {
            (succeeded: Bool, error: NSError?) -> Void in

            if (error == nil)
            {
                println("sign up success")
            }
            else
            {
                println("sign up failure! (alert the user!)")
            }
        }
    }
}

0 个答案:

没有答案