title: Stop a executing a function when if statement returns true
body: <p>I have an app that allows users to save their profile. In order for them to be able to sign up, I want to check and see if they have agreed to the apps terms and conditions. The issue I am having is if the user doesn't agree to them, they will see an alertController telling them to agree. However, the app still continues to execute the remainder of the code.</p>
  <pre><code>    func checkIfChecked() {
              
      if self.checkbox.imageView.isHidden == true {
          let alert = UIAlertController(title: &quot;Hold up!&quot;,message:&quot; You must agree to our Community Guidelines before you can sign up.&quot;, preferredStyle: UIAlertController.Style.alert)
          let continueButton = UIAlertAction(title: &quot;Got it!&quot;, style: .default, handler: {(_ action: UIAlertAction) -&gt; Void in
          
             })
   
          continueButton.setValue(GREEN_Theme, forKey: &quot;titleTextColor&quot;)
          alert.addAction(continueButton)
          self.present(alert, animated: true, completion: nil)
      }
      
      if self.checkbox2.imageView.isHidden == true {
          let alert = UIAlertController(title: &quot;Hold up!&quot;,message:&quot; You must agree to our Terms &amp; Conditions before you can sign up.&quot;, preferredStyle: UIAlertController.Style.alert)
          let continueButton = UIAlertAction(title: &quot;Got it!&quot;, style: .default, handler: {(_ action: UIAlertAction) -&gt; Void in
          
             })
   
          continueButton.setValue(GREEN_Theme, forKey: &quot;titleTextColor&quot;)
          alert.addAction(continueButton)
          self.present(alert, animated: true, completion: nil)
          
      }
      
  }
  
     @objc func handleRegister() {
      
      checkIfChecked()
  
      let hud = JGProgressHUD(style: .dark)
      hud.textLabel.text = &quot;Registering!&quot;
      hud.show(in: view)
      guard let email = emailTextField.text, let password = passwordTextField.text, let name = nameTextField.text, let phonenumber = phonenumberTextField.text else {
          print(&quot;Error&quot;)
          return
  </code></pre>
  <p>the remainder of code....
  }</p>
  <pre><code>}
  </code></pre>
  <p>if the checkBoxs are checked, there is no issue. But if they are not checked, then the users information will still be saved to the data base without them logging in. So I am trying to stop the execution of handleRegister after checkIfChecked is called only if the boxs were not checked.</p>