title: swift delegate beetween two view controller without segue
body: <h1>My delegate protocol never called</h1>
  
  <p>My first controller - ViewController </p>
  
  <pre><code>class ViewController: UIViewController,testProtocol {
  
      @IBAction func btInit(sender: AnyObject) {
          println("Bt Init")
  
          let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
          let initViewController: UIViewController = storyBoard.instantiateViewControllerWithIdentifier("viewTarget") as targetViewController
          self.presentViewController(initViewController,animated: false, nil)
  
      }
  
      var targetController = targetViewController();
  
      override func viewDidLoad() {
          super.viewDidLoad()
          self.targetController.delegate = self
      }
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
          // Dispose of any resources that can be recreated.
      }
  
      func testDelegate(){
          println(" in my view controller delegate ")
      }
  }
  </code></pre>
  
  <p>In my second view controller - targetViewController</p>
  
  <pre><code>protocol testProtocol {
      func testDelegate() // this function the first controllers
  }
  
  class targetViewController: UIViewController {
  
      @IBAction func BtTarget(sender: AnyObject) {
  
          println("bt target pressed")
  
          delegate?.testDelegate()
      }
  
      var delegate : testProtocol?
  
      override func viewDidLoad() {
          super.viewDidLoad()
      }
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
      }
  
      func testDelegate(){
          println(" in my target view controller delegate ")
      }
  }
  </code></pre>
  
  <p>Why is testDelegate() never called on ViewController? What am I doing wrong? Thanks.</p>
  
  <p>I have read a lot of posts about this, but all of the examples are given with segue transition, and I don't want use a segue.  </p>