title: How to create view from its parent's nib using Swift
body: <p>I thought this question is very simple but after long search without find an answer I'm trying to ask here:</p>
  
  <p>I have a custom view (MyCustomView:UIView) with a .xib file.
  To use this class with its nib I add a class function as following</p>
  
  <pre><code>class func addCustomViewToView(view: UIView)
  {
      let CV = NSBundle(forClass: MyCustomView.self).loadNibNamed("MyCustomView", owner: self, options: nil).first as! MyCustomView
      CV.frame = CGRectMake(0, 0, view.frame.width, view.frame.height)
      view.addSubview(CV)
  }
  </code></pre>
  
  <p>In another place in my application I had to extend my custom view so I created a subClass of my custom view:</p>
  
  <pre><code>class MyExtendedCustomClass : MyCustomClass
  { 
      ...
  }
  </code></pre>
  
  <p>I tried to override the class function, but I didn't find way to create a sub class item using parent's nib file.</p>
  
  <p>What is the correct way to do this?</p>
  
  <p>thanks   </p>