NSView subclass over another NSView subclass? <p>I'm trying to create an Cocoa-AppleScript Application with some basic functions, and I want to display a background image for the window and then display a color box above it. </p> <p>I finally figured out how to set the background image via this guide (<a href="http://www.mere-mortal-software.com/blog/details.php?d=2007-01-08" rel="nofollow noreferrer">http://www.mere-mortal-software.com/blog/details.php?d=2007-01-08</a>), but I don't know how to set a color box above it. The basic layout I'm trying to achieve is this:</p> <p><img src="https://i.stack.imgur.com/o25EI.png" alt="enter image description here"></p> <p>The window view has a class of <code>ViewBackground</code> which is a subclass of <code>NSView</code>. The <code>ViewBackground.m</code> file looks like this:</p> <pre><code>-(void)drawRect:(NSRect)rect { NSImage *anImage = [NSImage imageNamed:@"repeat"]; [[NSColor colorWithPatternImage:anImage] set]; NSRectFill([self bounds]); } </code></pre> <p>Like I said, that works fine. The problem is when I try to put the box with the background color white above it. I thought I would be able to do this by making a new subclass of <code>NSView</code>, <code>ContentBackground</code>. The <code>ContentBackground.m</code> file looks like this:</p> <pre><code>-(void)drawRect:(NSRect)rect { [[NSColor whiteColor] set]; NSRectFill(rect); } </code></pre> <p>The hierarchy of my windows looks like this:</p> <p><img src="https://i.stack.imgur.com/PzF0I.png" alt="enter image description here"></p> <p>Now this <em>sometimes</em> works, but usually produces this result in the debugger:</p> <pre><code>int main(int argc, char *argv[]) { [[NSBundle mainBundle] loadAppleScriptObjectiveCScripts]; return NSApplicationMain(argc, (const char **)argv); Thread 1: Stopped at breakpoint 1 } </code></pre> <p>What am I doing wrong and how can I fix this?</p> <p>Also, the content (buttons, etc..) will go on top of the <code>ContentBackground</code> box.</p>