2016-08-05 37 views
1

我正在嘗試創建一個註冊頁面,其中人們將他們的電子郵件和所需密碼等信息放入此處,然後我想切換到下一個視圖控制器,但出現以下錯誤未知的選擇器問題

[StudyBuddy.SignUpViewController signUpButton:]:無法識別的選擇發送到實例0x7fac5e061b80'

SignUpViewController

import UIKit 
import Firebase 
import CoreData 
import CoreLocation 

class SignUpViewController: UIViewController { 
    @IBOutlet weak var emailField: UITextField! 
    @IBOutlet weak var passwordField: UITextField! 
    @IBOutlet weak var confirmPasswordField: UITextField! 

    override func viewDidLoad() { 
     super.viewDidLoad() 
     if let user = FIRAuth.auth()?.currentUser { 



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

    override func didReceiveMemoryWarning() { 
     super.didReceiveMemoryWarning() 
     // Dispose of any resources that can be recreated. 
    } 
    @IBAction func signupButton(sender: AnyObject) 
    { 
    if self.emailField.text == "" || self.passwordField.text == "" { 

      let alertController = UIAlertController(title: "Oops!", message: "Please enter a valid username and password", preferredStyle: .Alert) 
      let defaultAction = UIAlertAction(title: "Ok", style: .Cancel, handler: nil) 
      self.presentViewController(alertController, animated: true, completion: nil) 

     } 

     else if self.confirmPasswordField.text != self.passwordField.text { 

      let passwordAlert = UIAlertController(title: "Oops!", message: "Passwords do not match", preferredStyle: .Alert) 
      let passwordAction = UIAlertAction(title: "Ok", style: .Cancel, handler: nil) 

      self.presentViewController(passwordAlert, animated: true, completion: nil) 
     } 

     else { 

      FIRAuth.auth()?.createUserWithEmail(emailField.text!, password: passwordField.text!, completion: {(user, error) in 

       if error == nil { 
        self.performSegueWithIdentifier("goToSignUp", sender: sender) 

       } 
       else { 
        let createAlert = UIAlertController(title: "There was a problem", message: "There was a problem creating your account, please check the information you provided and try again", preferredStyle: .Alert) 
        let createAction = UIAlertAction(title: "Ok", style: .Cancel, handler: nil) 
        self.presentViewController(createAlert, animated: true, completion: nil) 
       } 

       }) 
     } 


    } 

回答

1

你需要改變,因爲你的宣言u內側signUpButtonsignupButton方法聲明爲up你需要Up改變它,因爲方法名和屬性名是區分大小寫或者改變這個signupButton一個選擇器下後你在哪裏添加按鈕的目標。

+0

更正方法名稱和屬性是區分大小寫的。 – gurmandeep

+0

正確閱讀我的答案,你會得到答案,或者用這個'signUpButton'來改變你的方法聲明。只是大寫的'U' –

+0

更改func signupButton到func signUpButton – gurmandeep