Hi
I saw this confusing code. A variable is declared as sender: AnyObject, then the code refers to sender.tag.
@IBAction func loginAction(_ sender: AnyObject)
{
/
/
guard
let newAccountName = usernameTextField.text,
let newPassword = passwordTextField.text,
!newAccountName.isEmpty &&
!newPassword.isEmpty else {
let alertView = UIAlertController(title: "Login Problem",
message: "Wrong username or password.",
preferredStyle:. alert)
let okAction = UIAlertAction(title: "Foiled Again!", style: .default, handler: nil)
alertView.addAction(okAction)
present(alertView, animated: true, completion: nil)
return
}
/
usernameTextField.resignFirstResponder()
passwordTextField.resignFirstResponder()
/
if sender.tag == createLoginButtonTag {
etc
If I use the context menu item for the tag it takes me to this line in UIView.h, part of the declaration of @interface UIView
@property(nonatomic) NSInteger tag; // default is 0
How is that connected with sender: AnyObject?
The code comes from https://www.raywenderlich.com/147308/secure-ios-user-data-keychain-touch-id?utm_source=Swift_Developments
Does anyone know what is happening here?