title: Swift, iboutlet and custom controls
body: <p>I may be doing something really stupid, but I don't seem to be able to use Interface Builder to connect IBOutlet variables to custom views, but only in Swift.</p>
  
  <p>I've created a class called MyView, which extends from UIView. In my controller, I've got a MyView variable (declared as @IBOutlet var newView: MyView). I go into IB and drag a UIView onto the window and give it a class of MyView.</p>
  
  <p>Whenever I've done similar in Objective C, I'm then able to click on the View Controller button at the top of the app window, select the variable and drag it down to the control to link the two together. When I try it in Swift, it refuses to recognise that the view is there.</p>
  
  <p>If I change the class of the variable in the controller to UIView, it works fine. But not with my custom view.</p>
  
  <p>Has anyone else got this problem? And is it a feature, or just my idiocy?</p>
  
  <p>Code for Controller</p>
  
  <pre><code>import UIKit
  
  class ViewController: UIViewController {
  
      @IBOutlet var newView:MyView
  
      override func viewDidLoad() {
          super.viewDidLoad()
          // Do any additional setup after loading the view, typically from a nib.
      }
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
          // Dispose of any resources that can be recreated.
      }
  }
  </code></pre>
  
  <p>Code for view</p>
  
  <pre><code>import UIKit
  
  class MyView: UIView {
  
      init(frame: CGRect) {
          super.init(frame: frame)
          // Initialization code
      }
  
      /*
      // Only override drawRect: if you perform custom drawing.
      // An empty implementation adversely affects performance during animation.
      override func drawRect(rect: CGRect)
      {
          // Drawing code
      }
      */
  
  }
  </code></pre>