I have an application thats a mix of c++ and objective-c.
Quite a lot of the c++ classes exist merely as facades to access the underlying objective-c object from the rest of the x++ application.
My problem is one of design: The objective-c class needs to call back into the c++ class via a set of methods I'd prefer to mark as private - no other c++ class (not even derived classes) needs to be messing around with these.
But I can't mark them private, as there doesn't seem to be a way to make objective-c class methods 'friends' of a c++ class.
I considered cheating and using macro's to mark the c++ methods as public when __OBJC__
is defined, but that changes the method's decoration and would result in link errors.
anyone else encountered this?
// MyView.mm
@interface MyView : NSView {
@public
CMyView* _cpp;
}
-(void)drawRect:(NSRect)dirtyRect {
CGContextRef cgc = (CGContextRef)[[NSGraphicsContext currentContext]graphicsPort];
_cpp->Draw(cgc);
}
...
// MyView.h
class CMyView {
id _view;
public:
// this method should be private. It exists ONLY for the MyView obj-c class.
void OnPaint(CGContextRef cdc);
};