I’m using a 3rd party class that contain the following extention:
@interface BaseClass ()
{
int privateMember;
}
@end
i’ve created my own subclass:
@interface SubClass : BaseClass {
}
@end
is there a way to access privateMember in SubClass?
EDIT:
actual code
GPUImageMovie.m: (base class)
@interface GPUImageMovie ()
{
BOOL audioEncodingIsFinished, videoEncodingIsFinished;
GPUImageMovieWriter *synchronizedMovieWriter;
CVOpenGLESTextureCacheRef coreVideoTextureCache;
AVAssetReader *reader;
}
MultiTrackGPUImageMovie.h (subclass)
@interface MultiTrackGPUImageMovie : GPUImageMovie {
}
...
@end
MultiTrackGPUImageMovie.m (subclass)
- (void)processMovieFrame:(CMSampleBufferRef)movieSampleBuffer forTarget:(int)targetToSendIdx {
...
CVReturn err = CVOpenGLESTextureCacheCreateTextureFromImage(kCFAllocatorDefault, coreVideoTextureCache, movieFrame, NULL, GL_TEXTURE_2D, GL_RGBA, bufferWidth, bufferHeight, GL_BGRA, GL_UNSIGNED_BYTE, 0, &texture);
...
}
give error
Use of undeclared identifier ‘coreVideoTextureCache’
It depends on how the ‘private’ member has been declared. If there wasn’t the
@privatekeyword before it, i. e. it was reallyand not
then you can easily reference this instance variable simply by using its name – the default access scope for instance variables is protected, i. e. not accessible outside the class, but accessible from subclasses.
However, if it was declared as
private, you’ll have to fall back using the runtime functions; in your subclass, declare and implement this method:Then use it like this:
Edit: so it seems the member you’re trying to access is in a class extension and not public in the header file. In this case, you can go for the 2nd solution only (although it’s not advised to do so).