Note: This question doesn't have anything to do with the language used, i.e, Swift/ Objective-C
I can't seem to get my head around how such a problem can be solved. How an asynchronous method which processes data continuously ,return back these processed values to a function?
Example Class structure of -> ClassName
- A method named
-(void)infoCallBack
, this is the method you have to call to get returns continuously. - Inside
-(void)infoCallBack
-> an asynchronous method[self startRecording]
is there, which does audio recording asynchronously using AudioQueues by using a callback methodvoid AudioInputCallback(..param..)
. - Finally Inside
void AudioInputCallback(..param..)
-> a method-(void) processAudio
is there, which continuously processes data and gives us an integer number.
How to call a method like [ClassName infoCallBack]
in such a way that we keep getting all these processed integers continuously?
Edit : I have searched SO, and came across completion handler blocks : although completion handlers only return a value once after completionHandler()
is called. Moreover, another problem in this method was how to pass around this completionHandler
to multiple methods in the className Structure as shown.
I came across delegates, it said that when distinct values are being returned continuously and state of something changes, then we should call a delegate. But I was stuck at how I would return values after I call the function infoCallBack from ClassName, i.e, [ClassName infoCallBack]
which continuously can feed the person calling this function with the values being processed.