I have a int variable called recordingStatus.
I would like to “listen” to this recording status and update my label based on the status of this variable.
int recordingStatus;
@property (strong, nonatomic) IBOutlet UILabel *recordingStatusText;
The reason I have to do so is that recordingStatus is being changed in my C code (also in the same file) and the C code doesn’t have access to the UI elements (as far as I know).
What’s the most elegant way to do this in iOS?
C Code Core Audio Callback
static OSStatus rioRecordingCallback(void *inRefCon,
AudioUnitRenderActionFlags *ioActionFlags,
const AudioTimeStamp *inTimeStamp,
UInt32 inBusNumber,
UInt32 inNumberFrames,
AudioBufferList *ioData) {
// want to access recordingStatus in here, am I able to do it without passsing it in via inRefCon?
}
Thanks.
Pier.
There are multiple ways you can approach this. As Rickay noted, you can make it a property and just override the setters to set the value of your label as well.
The other approach is to use KVO to monitor
recordingStatus(it will still need to have a property). If you’re looking for a super awesome way to use KVO, check out ReactiveCocoa. This type of observe-react pattern is known as reactive programming.