Reputation: 29
Here is my code for login. As you can see, I have my username and password pre defined.
import UIKit
class ViewController: UIViewController {
@IBOutlet var _username: UITextField!
@IBOutlet var _password: UITextField!
@IBOutlet var _login_button: UIButton!
@IBOutlet var label: UILabel!
let username = "Kiarash"
let password = "Test"
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
@IBAction func LoginButton(_ sender: Any) {
if(_username.text == username && _password.text == password)
{
label.text = "You are Logged in!"
}
}
}
But when I enter the correct username and password, it throw below error.
unrecognized selector sent to instance 0x7f8b9450ac60
2020-05-03 19:44:02.481826-0700 KCMLogin[9156:552975] *** Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '-[UIView setText:]: unrecognized selector sent to instance 0x7f8b9450ac60'
I am not sure why this happen, Sorry I am a beginner.
Upvotes: 0
Views: 48
Reputation: 355
Remove the current Referencing Outlets
from label
and reconnect label
to view controller
.
Upvotes: 1