Sorry about the confusing title, I have this block of code running in its own thread and want to access a class variable inside another class (view controller) everytime its value changed.
To clarify my question here is a simple class structure that represent what I’m trying to accomplish.
@interface classB : NSObject
{
NSThread * _someThread;
}
+ (classB*) instance;
@property(atomic) CVPixelBufferRef pixBufB;
- (void) foo
{
while(1)
{
//decode a frame
//assign data to pixBufB
}
}
- (void) start
{
_someThread = [[NSThread alloc] initWithTarget:self selector:@selector(foo) object:nil];
}
//sampleViewController
@interface sampleViewController : UIViewController
@property(atomic) CVPixelBufferRef pixBuf;
- (void)viewDidLoad
{
[[classB instance] start];
}
- (void) bar
{
_pixBuf = [[classB instance] pixBufB];
}
At the end of each loop cycle in foo, I want to access _pixBufB inside sampleViewController class. Since foo is executed in another thread I can’t simply use a getter, does anyone know how to approach this issue?
Thanks