title: Delegate functions are not called - NSURLConnection
body: <p>I'm new to swift coding, so most of my code is "this is how I found it on the internet" status.</p>
  
  <p>I'm trying to send a HTTP GET request and then work with it. I'm using <code>NSURLConnection</code> for this. I have 2 swift files in my Xcode project (it is a swift console project, not playground), one is main one and 2nd contains my class I would like to use for delegation:</p>
  
  <pre><code>import Foundation
  
  class Remote: NSObject, NSURLConnectionDelegate {
  
      var data = NSMutableData()
  
      func connect() {
          var url =  NSURL(string: "https://www.google.com")
          var request = NSURLRequest(URL: url!)
  
          NSLog("Is%@ main thread", NSThread.isMainThread() ? "" : " NOT");
          var conn = NSURLConnection(request: request, delegate: self, startImmediately: false)
          conn?.scheduleInRunLoop(NSRunLoop.mainRunLoop(), forMode: NSDefaultRunLoopMode)
          conn?.start()
  
          sleep(2)
      }
  
  
      func connection(didReceiveResponse: NSURLConnection!, didReceiveResponse response: NSURLResponse!) {
          println("didReceiveResponse")
      }
  
      func connection(connection: NSURLConnection!, didReceiveData conData: NSData!) {
          println("didReceiveData")
      }
  
      func connectionDidFinishLoading(connection: NSURLConnection!) {
          println("DidFinishLoading")
      }
  
      deinit {
          println("deiniting")
      }
  
  }
  </code></pre>
  
  <p>Here is my main swift code:</p>
  
  <pre><code>import Foundation
  
  var xxx = Remote()
  xxx.connect()
  
  sleep(10)
  
  sleep(2)
  </code></pre>
  
  <p>When I set breakpoints on each <code>println</code> in delegate functions, they are never hit. Execution is done from main thread according to <code>NSLog</code> output.</p>
  
  <p>In debugger I can see that data are sent and received over the network, but I never get any output. I've seen many similar questions here but nothing helped me.</p>
  
  <p>What am I doing wrong?</p>