title: When is "required init?(coder aDecoder: NSCoder)" called on a UIView or UIViewController?
body: <p>When I create a subclass of <code>UIView</code> or <code>UIViewController</code> with a stored property, Xcode will not compile my project unless I include an implementation of <code>required init?(coder aDecoder: NSCoder)</code>. Currently, I have the following implementation to shut the compiler up:</p>
  
  <pre><code>required init?(coder aDecoder: NSCoder) {
      fatalError()
  }
  </code></pre>
  
  <p>I understand why I'm required to include this initializer; my subclass needs to conform to the <code>NSCoding</code> protocol because its superclass conforms to it, and this initializer is part of the <code>NSCoding</code> protocol so it needs to work with my class, i.e. initialize all of my class's stored properties (which the superclass version of the initializer won't do).</p>
  
  <p>I imagine that a correct implementation would look something like this:</p>
  
  <pre><code>class MyView: UIView {
      let label: UILabel
  
      override init(frame: CGRect) {
          label = UILabel()
          super.init(frame: frame)
      }
  
      required init?(coder aDecoder: NSCoder) {
          if let label = aDecoder.decodeObject() as? UILabel {
              self.label = label
          } else {
              return nil
          }
          super.init(coder: aDecoder)
      }
  
      override func encode(with aCoder: NSCoder) {
          aCoder.encode(label)
          super.encode(with: aCoder)
      }
  }
  </code></pre>
  
  <p>However, considering that my application has over 50 custom views and view controllers, correctly implementing this function in every custom view and view controller is a lot of work.</p>
  
  <p>So, I'm wondering if it's necessary to implement this initializer correctly, or if I can just leave it throwing a fatal error. In other words, <strong>will this initializer ever be called if I don't call it in my own code?</strong> I think I read that it might be called by a Storyboard, but my app doesn't use any Storyboards.</p>