The solution proposed by the S.O. post you link could be implemented in this way:
1) create a wrapper to MGTwitterEngine; this wrapper will expose any selector you need of MGTwitterEngine and will add to each of them a parameter which identifies the view controller that is calling it;
2) your wrapper to MGTwitterEngine would act as a unique delegate to all requests sent;
3) for each request that the wrapper receives from a view controller, the wrapper will store the view controller address in a NSMutableDictionary associated to the twitter id;
4) when a response comes back, the delegate (which is the same object as the wrapper) will find out which view controller sent the request initially (by searching in the dictionary for the twitter id that came with the response), and forward the response to it.
I hope this helps....
EDIT:
this is how you could do it (I am including only 1 API call and just the relevant code):
@interface TwitterClientViewController : UIViewController <MGTwitterEngineDelegate> {
}
@end
@implementation TwitterClientViewController;
- (void)requestListOfUsers:(NSString*)username {
[twitterEngineSingleton getListsForUser:username requestDelegate:self];
}
- (void)requestSucceeded:(NSString*)connectionIdentifier {
NSLog(@"Hello");
}
@end
@interface AdvancedTwitterEngine : NSObject <MGTwitterEngineDelegate> {
MGTwitterEngine* _engine;
NSMutableDictionary* _callerIds;
}
-(NSString*)getListsForUser:(NSString*)username requestDelegate:(id<MGTwitterEngineDelegate>)delegate;
@end
@implementation AdvancedTwitterEngine;
-(void)init {
if (self = [super init]) {
_engine = [[MGTTwitterEngine alloc] initWithDelegate:self];
_callerIds = <init>
}
return self;
}
-(NSString*)getListsForUser:(NSString*)username requestDelegate:(id<MGTwitterEngineDelegate>)delegate {
NSString* twId = [_engine getListsForUser:username];
[_callerIds setObject:controller forKey:twId];
return twId;
}
//-- delegate methods
- (void)requestSucceeded:(NSString*)connectionIdentifier {
id<MGTwitterEngineDelegate> dlg = [_callerIds objectForKey:connectionIdentifier];
[dlg requestSucceeded:connectionIdentifier];
}
@end