title: Timeout function after 10 seconds Swift/iOS
body: <p>I want to display a "Network Error" message if after 10 seconds of trying to connect, a login does not succeed. </p>
  
  <p>How can I stop my login function after 10 seconds and show this error message?</p>
  
  <p>I'm using AlamoFire.</p>
  
  <p>I don't have the full implementation, but this is the skeleton of what I want my function to behave like:</p>
  
  <pre><code>func loginFunc() {
  
      /*Start 10 second timer, if in 10 seconds 
       loginFunc() is still running, break and show NetworkError*/
  
  
      &lt;authentication code here&gt;
  }
  </code></pre>