I assume that walking through a delegate object that refers to a selector method and calling this method with the processed data will be a good way to achieve the loosely coupled structure that your program deserves. Are you familiar with this concept or will I dig you some code samples?
UPDATE: Code Samples
So, I would probably use the calling class, say MyViewController , to implement callbackMethod, myCallbackMethod as follows:
-(void) myCallbakcMethod: NSMutableArray* array {
The point is to return the result to this method when the calculation is complete. Therefore, in MyViewController , where you call MethodA , you pass a reference to the delegate to handle the result, namly self .
MyModel MethodA and methodB need to add the (id)delegate parameter and pass this between calls.
In methodB , where myArray data is ready, make the following call:
if([delegate respondsToSelector:@selector(myCallbackMethod:)]]) [observer performSelector:@selector(myCallbackMethod:) withObject:myArray];
source share