I tried to get OpenGL ES native window (_win) from class:
@interface CAEAGLLayer : CALayer <EAGLDrawable>
{
@private
struct _CAEAGLNativeWindow *_win;
}
so I extended it with category:
@interface CAEAGLLayer(MyLayer)
- (void*) fetchWin;
@end
@implementation CAEAGLLayer(MyLayer)
- (void*) fetchWin
{
return self->_win;
}
@end
And use it in another Class:
@implementation MyClass
- (void)setupLayer
{
_eaglLayer = (CAEAGLLayer*)self.layer;
_eaglLayer.opaque = YES;
NSLog(@"_eaglLayer _win: %p", [_eaglLayer fetchWin]);
}
@end
But when building, met a link error:
Undefined symbols for architecture x86_64:
"_OBJC_IVAR_$_CAEAGLLayer._win", referenced from:
-[CAEAGLLayer(MyLayer) fetchWin] in OpenGLView.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)