Cocoa->Carbon (NSView to WindowRef)

DustinM

Registered
I am porting a Windows app to MacOSX and have some code written in Cocoa that has an NSView that I need to attach an OpenGL rendering context to (via the aglFuncs...(...)). I am interfacing with a large, existing C++ code base so re-engineering everything for Cocoa is not an option, neither is using the "Cocoa friendly" OpenGL calls. What I am trying is:

Code:
NSView * pNSView = pSomeKnownNSView;
NSWindow * pNSWindow = [pNSView window];
WindowRef refWindow = (WindowRef)[pNSWindow windowRef]
However, I am getting the compile warning:
Warning: no "-windowRef" method found

2 questions... 1) Am I taking the correct path for what I want to do? 2) According to Apple's Cocoa reference docs (http://developer.apple.com/document...ow.html#//apple_ref/doc/uid/20000013-BCIJDAGE), the windowRef function exists (and I did check the NSWindow.h in the AppKit Framework)... any ideas why I am getting this and how I can remove the warning?

Thanks!
Dustin
 
One nit picking comment... don't use "NS" in your variable names... it's not good programming style.... NS just exists because Cocoa doesn't have namespaces (and it helps to identify who made the class). If NS wasn't used, then you could never make your own classes called "Window" or "String" or whatever... :)
 
Back
Top