title: Identifying UITextField when using a UITextField Collection in Swift iOS
body: <p>I am creating a signup screen.
  There are four UITextField, which is the ID, password, password check, name,
  I am <code>@Iboutlet var signupTextFields: [UITextField]!</code> I connected it. After that, I want to make an ID, password validation.</p>
  <p>First, I divided ViewController and UItextFieldDelegate.</p>
  <pre><code>class SignUpViewController: UIViewController {
      
      @IBOutlet var signUpTextFields: [UITextField]! {
          didSet {
              signUpTextFields.forEach { textField in
                  textField.delegate = textFieldDelegate
                  textField.returnKeyType = .next
              }
          }
      }
      @IBOutlet weak var nextButton: UIButton!
      
      private lazy var textFieldDelegate = TextFieldDelegate(self)
      
      override func viewDidLoad() {
          super.viewDidLoad()
          signUpTextFields.first?.becomeFirstResponder()
      }
      
      @IBAction func nextButtonTapped(_ sender: UIButton) {
      }
  }
  </code></pre>
  <pre><code>class TextFieldDelegate: NSObject, UITextFieldDelegate {
      private weak var signUpViewController: SignUpViewController?
      
      init(_ signUpViewController: SignUpViewController) {
          self.signUpViewController = signUpViewController
      }
      
      func textFieldDidBeginEditing(_ textField: UITextField) {
          textField.layer.borderWidth = 1
          textField.layer.borderColor = UIColor.systemBlue.cgColor
      }
  
      func textFieldDidEndEditing(_ textField: UITextField, reason: UITextField.DidEndEditingReason) {
          textField.layer.borderColor = UIColor.black.cgColor
      }
  
      func textFieldShouldReturn(_ textField: UITextField) -&gt; Bool {
          textField.resignFirstResponder()
          return true
      }
  }
  </code></pre>
  <p>The problem when using the functions provided by Delegate is that the example code is to identify UITextField using if-else, such as</p>
  <pre><code>func textFieldDidBeginEditing(_ textField: UITextField) {
      if textField == idTextField {
        //code
      } else if textField == passwordTextField {
        //code
      }
  }
  </code></pre>
  <p>I was not this way, but I thought I wanted to abstract the uitextfield a little more to use the Factory method or polymorphism.</p>
  <p>Is there a way to identify a UITextField Collection without using if-Else?</p>