title: Cancel loading after 10 second
body: <p>I want to cancel loading data from the internet if it takes more than 10 second, because there is only one text.</p>
  
  <pre><code>let date_start = NSDate()
  
  let jsonUrl = "http://example.com"
  let session = NSURLSession.sharedSession()
  let shotsUrl = NSURL(string: jsonUrl)
  let task = session.dataTaskWithURL(shotsUrl!) {
    (data, response, error) -&gt; Void in
      do {
        let jsonData = try NSJSONSerialization.JSONObjectWithData(data!, options:NSJSONReadingOptions.MutableLeaves ) as! NSDictionary
        // saving data
        dispatch_async(dispatch_get_main_queue(), {
          self.tableView.reloadData()
          print("getJson: \(-date_start.timeIntervalSinceNow)")
        });
  
      } catch _ {
        // Error
      }
  }
  task.resume()
  </code></pre>
  
  <p>Can't figure out how to stop loading, I want something like this</p>
  
  <pre><code>var timer = NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: Selector("check"), userInfo: nil, repeats: true)
  
  func check() 
  {
      if -date_start.timeIntervalSinceNow) &gt; 10.0 {
          // stop loading
      }
  }
  </code></pre>
  
  <p>Thanks!</p>