title: How to load custom UIView from xib using Swift 2?
body: <p>The task is to create custom UIView that loads UI from .xib file using Swift. How do I do that?</p>
  
  <p>I tried to do that using the code:</p>
  
  <pre><code>import UIKit
  
  @IBDesignable class CustomView: UIView {
  
  var view: UIView!
  
  @IBOutlet weak var label: UILabel!
  
  override init(frame: CGRect) {
      super.init(frame: frame)
      xibSetup()
  }
  
  required init?(coder aDecoder: NSCoder) {
      super.init(coder: aDecoder)
      xibSetup()
  }
  
  func xibSetup() {
      view = loadViewFromNib()
      view.frame = bounds
      view.autoresizingMask = [UIViewAutoresizing.FlexibleWidth, UIViewAutoresizing.FlexibleHeight]
  
      addSubview(view)
  }
  
  func loadViewFromNib() -&gt; UIView {
      let bundle = NSBundle(forClass: self.dynamicType)
      let nib = UINib(nibName: "CustomView", bundle: bundle)
      let view = nib.instantiateWithOwner(self, options: nil)[0] as! UIView
  
      return view
  }
  
  }
  </code></pre>
  
  <p>It runs, but crashes with EXC_BAD_ACCESS and shows me the message: </p>
  
  <pre><code>warning: could not load any Objective-C class information. This will significantly reduce the quality of type information available.
  </code></pre>
  
  <p>Actually, I need to translate code given here <a href="http://qnoid.com/2013/03/20/How-to-implement-a-reusable-UIView.html" rel="nofollow">http://qnoid.com/2013/03/20/How-to-implement-a-reusable-UIView.html</a> to Swift 2.0, but I have no idea how to do this.</p>