title: how to notify a UIViewController that a button was clicked in a xib file using a delegate in swift?
body: <p>I'm a bit stuck.
  I have a <code>UIViewController</code> and a custom <code>pop.xib</code> that extends <code>UIView</code>. 
  <code>pop.xib</code> is connected to <code>pop.swift</code>.
  In the <code>UIViewController</code> a button makes the <code>.xib</code> file pop up.</p>
  
  <p>And in <code>pop.xib</code> there is a button that is clicked to send some data to the database. </p>
  
  <p>But when that button is clicked in <code>pop.xib</code> to send data I want the <code>UIViewController</code> to </p>
  
  <p>a) know when the <code>@IBAction func sendDataToDbAction(_ sender: Any)</code> is clicked and </p>
  
  <p>b) when the if statement returns false from inside <code>sendDataToDbAction</code> then present an alert on the <code>UIViewController</code></p>
  
  <pre><code>//pop.swift
  
       class Pop: UIView {
  
              @IBOutlet var delegate: AnswerDelegate?
  
              @IBAction func sendDataToDbAction(_ sender: Any)
              {
                       if(answer == false)
                       {
                            don't send to db
                            alert pops up saying answer is false
                       }
                       else
                       {
  
                       }
  
              }
           }
  </code></pre>
  
  <p>I've set up a delegate in pop.swift</p>
  
  <pre><code>//pop.swift
  
  @objc protocol AnswerDelegate {
  
      func isCorrectAnswer()
  }
  
  
  
  //UIViewController
  
  extension UIViewController:AnswerDelegate{
  
  //set the pop.xib delegate to self
  // implement func isCorrectAnswer
  
  }
  </code></pre>
  
  <p>I'm just not sure how I can use the delegate to do what I want.</p>
  
  <p>Thanks.</p>