title: How Does AnyObject Conform to NSObjectProtocol?
body: <p>This question was inspired by <a href="https://stackoverflow.com/a/36851435/2415822">mz2's answer</a> on the question <a href="https://stackoverflow.com/q/36850196/2415822">Check for object type fails with &quot;is not a type&quot; error</a>.</p>
  
  <p>Consider an empty Swift class:</p>
  
  <pre><code>class MyClass { }
  </code></pre>
  
  <p>Attempting to call any <code>NSObjectProtocol</code> methods on an instance of this class will result in a compile-time error:</p>
  
  <pre><code>let obj = MyClass()
  obj.isKindOfClass(MyClass.self) // Error: Value of type 'MyClass' has no member 'isKindOfClass'
  </code></pre>
  
  <p>However, if I cast the instance as <code>AnyObject</code>, my object now conforms to <code>NSObjectProtocol</code> and I can call the instance methods defined by the protocol:</p>
  
  <pre><code>let obj: AnyObject = MyClass()
  obj.isKindOfClass(MyClass.self) // true
  obj.conformsToProtocol(NSObjectProtocol) // true
  obj.isKindOfClass(NSObject.self) // false
  </code></pre>
  
  <p>My object doesn't inherit from <code>NSObject</code>, but still conforms to <code>NSObjectProtocol</code>.  How does <code>AnyObject</code> conform to <code>NSObjectProtocol</code>?</p>