2017-07-25 1 views
-3

もう一度、noobの質問でそれに戻ります。私は次のエラーを取得するいくつかの理由このクラスは、キーのキー値に符合していません。UserEmailAdresLogin

2017年7月25日14:29:00.589401 + 0200 Yiives [1416:534883] ***キャッチされない例外が原因アプリ 'NSUnknownKeyException'、理由の終了: '[setValue:forUndefinedKey:]:このクラスはキーUserEmailAdresLoginのキー値に符合していません。'

今私は自分自身で問題を見るために緑になるので、私を啓発してください。

ログインビューを読み込むことはできません。だから、どのように私はそれを実現することができます:D

は、私は次のコードを実行します。

import UIKit 

class LoginViewController: UIViewController { 

    @IBOutlet weak var BackgroundButton: UIButton! 

    @IBOutlet weak var UserEmailAdresInput: UITextField! 

    @IBOutlet weak var UserPasswordInput: UITextField! 

    @IBOutlet weak var UserLogin: UIButton! 

    @IBOutlet weak var UserForgotPassword: UIButton! 


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

    @IBAction func CloseLogin(_ sender: Any) { 

     dismiss(animated: true, completion: nil) 
    } 

    @IBAction func Login(_ sender: Any) { 

     let UserEmail = UserEmailAdresInput.text 
     let UserPassword = UserPasswordInput.text 

     let UserEmailStored = UserDefaults.standard.string(forKey: "UserEmail"); 

     let UserPasswordStored = UserDefaults.standard.string(forKey: "UserPassword"); 

     if(UserEmailStored == UserEmail){ 
      if(UserPasswordStored == UserPassword){ 

       //Login is succesfull 

       UserDefaults.standard.set(true, forKey: "UserLoggedIn") 
       UserDefaults.standard.synchronize(); 

      } 


     } 
    } 

} 


If you need the source where the data is bein inserted: 

import UIKit 

class EntryViewController: UIViewController, UITextFieldDelegate { 

    @IBOutlet weak var UserEmailAdresInput: UITextField! 

    @IBOutlet weak var UserPasswordInput: UITextField! 

    @IBOutlet weak var UserPasswordInputRepeated: UITextField! 

    @IBOutlet weak var UserSignUp: UIButton! 

    override func viewDidLoad() { 
     super.viewDidLoad() 

     self.UserEmailAdresInput.delegate = self 
     self.UserPasswordInput.delegate = self 
     self.UserPasswordInputRepeated.delegate = self 


    } 

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

    //Hide Keyboard upon Touch 

    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?){ 
     self.view.endEditing(true) 
    } 

    //Hide Keyboard upon Return Key 
    func textFieldShouldReturn(_ textField: UITextField) -> Bool { 
     if textField == UserEmailAdresInput{ 
      UserEmailAdresInput.resignFirstResponder() 
     } else if textField == UserPasswordInput{ 
      UserPasswordInput.resignFirstResponder() 
     } else { 
      UserPasswordInputRepeated.resignFirstResponder() 
     } 
     return true 
    } 

    @IBAction func SignUp(_ sender: Any) { 

     let UserEmail = UserEmailAdresInput.text; 
     let UserPassword = UserPasswordInput.text; 
     let UserPasswordRepeated = UserPasswordInputRepeated.text; 



     //Check if fields are filled in correctly 

     if(UserEmail?.isEmpty == true || UserPassword?.isEmpty == true || UserPasswordRepeated?.isEmpty == true){ 

      displayAlertMessage(userMessage: "Alle velden moeten ingevuld worden"); 
      return; 
     } 

     if UserEmail?.range(of: "@") == nil{ 
      displayAlertMessage(userMessage: "Vul een legitiem emailadres in"); 
      return; 
     } 

     if (UserPassword?.characters.count)! < 5{ 
      displayAlertMessage(userMessage: "Wachtwoord moet langer zijn dan 5 karakters"); 
     } 

     if(UserPassword != UserPasswordRepeated){ 

      displayAlertMessage(userMessage: "Wachtwoorden zijn niet gelijk"); 
      return; 
     } 

     //Store Data 
     UserDefaults.standard.set(UserEmail, forKey: "UserEmail"); 
     UserDefaults.standard.set(UserPassword, forKey: "UserPassword"); 
     UserDefaults.standard.synchronize(); 

     //SignUp Succesfull 
     var Alert = UIAlertController(title:"Succesvol aangemeld!", message: "Ga naar je email inbox om je aanmelding te voltooien", preferredStyle: UIAlertControllerStyle.alert); 

     let OkAction = UIAlertAction(title:"Ok", style: UIAlertActionStyle.default, handler: nil); 

     Alert.addAction(OkAction); 
     self.present(Alert, animated: true, completion: nil) 


    } 

    func displayAlertMessage(userMessage:String){ 

     var Alert = UIAlertController(title:"Melding", message: userMessage, preferredStyle: UIAlertControllerStyle.alert); 

     let OkAction = UIAlertAction(title:"Ok", style: UIAlertActionStyle.default, handler: nil); 

     Alert.addAction(OkAction); 

     self.present(Alert, animated: true, completion: nil) 

    } 

} 
+3

ストーリーボードとメールのアウトレットを確認してください。あなたのコードにはUserEmailAdresLoginという名前のコンセントはありませんが、あなたのストーリーボードにはそれがあります。 UserEmailAdresLoginという名前でコンセントを作成してから削除しましたか? SBからの削除を忘れましたか? –

+0

あなたのストーリーボードをレビューするには、関連コードから削除されたあなたのストーリーボードにアウトレットがリンクされている必要があります。 –

+0

これはすべて私がやったことでした。しかし、あなたがすでにアウトレットを持っている場合は、 –

答えて

1

このエラーは、UserEmailAdresLoginという変数へのリンク(私はあなたのストーリーボードファイルに思う)が、この変数なしを持っていることを意味しますあなたのコードソースにもっと長い時間存在します。 これをチェックするには、ストーリーボードのコントローラを右クリックすると、リンクのリストが表示され、十字をクリックするだけで削除されます。

問題がストーリーボードにない場合は、変数名の入力ミスです(「アドレス」と書かれていなければなりません)。

関連する問題