title: NSOpenGLView Cocoa (again)
body: <p>I'm new to the whole Cocoa/Objective-C malarky (but have years of C/C++ on *nix).</p>
  
  <p>I'm trying to create a basic Cocoa application that is filled with an NSOpenGLView. I have:</p>
  
  <p>chink.mm</p>
  
  <pre><code>#import &lt;OpenGL/gl.h&gt;
  #import "chink.h"
  
  @implementation chinkView
  
  @synthesize window;
  
  - (void) applicationDidFinishLaunching : (NSNotification *)aNotification {
      NSLog(@"Danger, Will Robinson! Danger!");
  }
  
  - (void) dealloc
  {
      [window release];
      [super dealloc];
  }
  
  @end
  </code></pre>
  
  <p>and chink.h</p>
  
  <pre><code>@interface chinkView : NSOpenGLView {
  
      NSWindow *window;
  
  }
  
  
  @property (assign) NSWindow *window;
  
  
  @end
  </code></pre>
  
  <p>I have a single .xib set up like</p>
  
  <p><a href="https://skitch.com/cront/ri625/chinkxib" rel="nofollow">https://skitch.com/cront/ri625/chinkxib</a></p>
  
  <p>where 'chink View' is set as delegate for Window and File Owner.</p>
  
  <p>I'm getting an 'invalid drawable' error (even before the application finished launching), which to my understanding means that it is trying to instantiate the opengl view before the window (although I'm probably wrong).</p>
  
  <p>What I want is the solution to this problem of creating the window and setting the opengl view inside it. Once this is done I have absolutely no problem writing the OGL (like I said, I know C++) but all this NS calls gunk is alien to me.</p>
  
  <p>I'm not looking for 'why don't you do it in SDL/GLUT' answers please. Just the code to make it create the window properly.</p>