title: NSView subviews and types
body: <p>I have a couple of custom NSBox subclasses called OuterBox and InnerBox. I've set up my view in a XIB and arranged the hierarchy like this:</p>
  
  <pre><code>OuterBox : NSBox
      NSButton
      NSBox
      InnerBox : NSBox
      ...and some other views
  </code></pre>
  
  <p>The idea is that when the NSButton gets pressed, in an IBAction method, I want to get the superview of the button and then, from that, get the InnerBox that is in the same OuterBox as the button.</p>
  
  <p>To do this, I loop through the OuterBox's subviews and check their type:</p>
  
  <pre><code>for (NSObject *subview in [outerBox subviews]) {
      // this never evaluates to true...
      if ([subview isKindOfClass:[InnerBox class]]) {
          // ...
      }
  }
  </code></pre>
  
  <p>The problem is that my <code>if</code> statement never hits. <code>subview</code> shows up in the debugger as an NSView. According to the documentation, <code>isKindOfClass:</code></p>
  
  <blockquote>
    <blockquote>
      <p>returns <code>YES</code> if the receiver is an instance of aClass or an instance of any class that inherits from aClass, otherwise <code>NO</code>.</p>
    </blockquote>
  </blockquote>
  
  <p>I understand why it's returning <code>NO</code>: because InnerBox is a type of NSView but not vice versa. But I don't know why <code>subview</code> is a UIView when it should be an InnerBox.</p>
  
  <p>I have imported InnerBox.h and made sure that the InnerBox really is an InnerBox in the XIB. I don't know what could be causing its type to get changed, or be reported incorrectly...</p>