title: How to add observer for subviews.count in UIView?
body: <p>I need to detect when number of subviews changes and perform a job then. How to add an observer and get a callback when it changes?</p>
  
  <p>So far I have tried within <code>AppDelegate</code>:</p>
  
  <pre><code>private func setupObserver() {
      window?.addObserver(self, forKeyPath: "subviews.count", options: NSKeyValueObservingOptions.new, context: nil)
  }
  
  override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
      print(keyPath)
  }
  </code></pre>
  
  <p>but it crashes:</p>
  
  <blockquote>
    <p>Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '[&lt;__NSArrayM 0x6000002520f0> addObserver:forKeyPath:options:context:] is not supported. Key path: count'</p>
  </blockquote>