Apple has a sample code project called GLEssentials that shows exactly how to do this (note that it is a Mac OS X and iOS sample code project).
Essentially you will need to subclass NSOpenGLView (the NSGLView class in the sample code) and implement the awakeFromNib method using the following:
- (void) awakeFromNib
{
NSOpenGLPixelFormatAttribute attrs[] =
{
NSOpenGLPFADoubleBuffer,
NSOpenGLPFADepthSize, 24,
// Must specify the 3.2 Core Profile to use OpenGL 3.2
NSOpenGLPFAOpenGLProfile,
NSOpenGLProfileVersion3_2Core,
0
};
NSOpenGLPixelFormat *pf = [[[NSOpenGLPixelFormat alloc] initWithAttributes:attrs] autorelease];
if (!pf)
{
NSLog(@"No OpenGL pixel format");
}
NSOpenGLContext* context = [[[NSOpenGLContext alloc] initWithFormat:pf shareContext:nil] autorelease];
[self setPixelFormat:pf];
[self setOpenGLContext:context];
}
Also remember that if you use any OpenGL API calls that have been removed from the 3.2 API your app will crash. Here is a PDF document of the 3.2 spec so you can see the changes.