title: NSOpenGLView with OpenGL 3.2 Core
body: <p>I apologies in advance if this question will be trivial or a nonsense...this is one of the first app that I'm developing. (Unfortunatley) I'm not a developer.</p>
  
  <p>I have a NSWindow which contains a custom View which is a subclass of <code>NSOpenGLView</code>.</p>
  
  <p>Since the <code>NSWindow</code> and the <code>NSOpenGLView</code> are created through Interface Builder, I don't need to <code>init</code> neither <code>NSOpenGLContext</code> nor <code>NSOpenGLPixelFormat</code>.</p>
  
  <p>I've recently switched to OS X Lion and I now want to leverage new OpenGL 3.2.</p>
  
  <p>From Apple documentation I found out that to enable OpenGL 3.2 I simply need to write something like:</p>
  
  <pre><code>NSOpenGLPixelFormatAttribute pixelFormatAttributes[] =
      {
          NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core,
          0
      };
  
      NSOpenGLPixelFormat *pixelFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes:pixelFormatAttributes] autorelease];
      NSOpenGLContext* openGLContext = [[[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:nil] autorelease];
  </code></pre>
  
  <p>before initializing the <code>NSOpenGLContext</code>.</p>
  
  <p>This is quite easy (even for me), but how can I implement this in my app since I never <code>init</code> <code>NSOpenGLContext</code>?</p>
  
  <p>Since the <code>NSOpenGLView</code> is created from Interface Builder, the method <code>-initWithFormat:shareContext:</code> doesn't get called.</p>
  
  <p>Therefore I tried to override the <code>-initWithCoder:</code> method with something like this:</p>
  
  <pre><code>-(id)initWithCoder:(NSCoder *)aDecoder
  {
   NSOpenGLPixelFormatAttribute pixelFormatAttributes[] =
      {
          NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core,
          0
      };
  
      NSOpenGLPixelFormat *pixelFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes:pixelFormatAttributes] autorelease];
      NSOpenGLContext* openGLContext = [[[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:nil] autorelease];
      [super initWithCoder:aDecoder];
      [self setOpenGLContext:openGLContext];
      [openGLContext makeCurrentContext];
  }
  </code></pre>
  
  <p>and OpenGL 3.2 is correctly loaded as reported by <code>glGetString(GL_VERSION)</code> but the created Context is no longer interacting with the app...nothing is drawn in the view..</p>
  
  <p>I tried everything I know of...but I'm not able to solve this.</p>
  
  <p>How should I do instead?</p>