title: how to set up a search with an "if" statement for arrays, very basic app (swift)
body: <p>I'm working on a basic app which has a listArray with ~1400 items, each with 3 properties (<strong>icao</strong>, <strong>callsign</strong>, image). It has 2 outlets: a &quot;textField&quot; and a &quot;label&quot;. With my custom keyboard(buttons) i can write 3 characters into my &quot;textField&quot;. And if these 3 characters are matching with the <strong>icao</strong> item of my listArray, then I would like the <strong>callsign</strong> item to be shown in my &quot;label&quot;. Is there a way to do it with an &quot;if&quot; statement? I would like to see &quot;AMERICAN&quot; in the &quot;label&quot;. Here is what I have:
  <a href="https://i.stack.imgur.com/urEuU.jpg" rel="nofollow noreferrer">my xcode and simulator screens</a></p>
  <pre><code>  @IBOutlet var ICAOtextField: UITextField!
  @IBOutlet var callsignTextLabel: UILabel!
  
  var updatedICAOtextField = &quot;&quot;
  var listArray = [list]()
  
  override func viewDidLoad() {
      super.viewDidLoad()
      setUpList()
  }
  
  private func setUpList() {
  
  listArray.append(list(icao: &quot;AAB&quot;, callsign: &quot;A-B-G&quot;, image: &quot;BELGIUM&quot;))
  listArray.append(list(icao: &quot;AAC&quot;, callsign: &quot;ARMYAIR&quot;, image: &quot;UK&quot;))
  listArray.append(list(icao: &quot;AAF&quot;, callsign: &quot;AZUR&quot;, image: &quot;FRANCE&quot;))
  listArray.append(list(icao: &quot;AAL&quot;, callsign: &quot;AMERICAN&quot;, image: &quot;USA&quot;))
  }
  
  @IBAction func abcButton(_ sender: UIButton) {
      
      updatedICAOtextField = ICAOtextField.text! + sender.currentTitle!
      ICAOtextField.text = updatedICAOtextField
      
      if updatedICAOtextField.count &gt; 3 {
          ICAOtextField.text = &quot;&quot;
      }
      
      if ICAOtextField.text ==                           {
          
          callsignTextLabel.text = &quot;            &quot;
      }
      
  }
  </code></pre>