title: swift delegation - when to use weak reference, why 'delegate' is nil?
body: <p>Here is my code:</p>
  
  <pre><code>protocol Delegate: NSObjectProtocol {}
  
  class A: NSObject {
      weak var delegate: Delegate!
      override init() {
          super.init()
      }
      func start() {
          //synchronous------- print A: false
          print("A:", delegate == nil)
  
          //asynchronous------- print B: true  Why is 'true'? How can do that not be released?
          let time: NSTimeInterval = 1
          let delay = dispatch_time(DISPATCH_TIME_NOW, Int64(time * Double(NSEC_PER_SEC)))
          dispatch_after(delay, dispatch_get_main_queue()) {
              print("B:", self.delegate == nil)
          }
      }
  }
  
  class B: NSObject, Delegate {
      override init() {
          super.init()
          let a = A()
          a.delegate = self
          a.start()
      }
  }
  </code></pre>
  
  <p>I searched for other questions on stack overflow but I can't find something that can help me to fully understand this situation.</p>