Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The solution proposed by the S.O. post you link could be implemented in this way:</p> <p>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;</p> <p>2) your wrapper to MGTwitterEngine would act as a unique delegate to all requests sent;</p> <p>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;</p> <p>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.</p> <p>I hope this helps....</p> <p>EDIT:</p> <p>this is how you could do it (I am including only 1 API call and just the relevant code):</p> <pre><code>@interface TwitterClientViewController : UIViewController &lt;MGTwitterEngineDelegate&gt; { } @end @implementation TwitterClientViewController; - (void)requestListOfUsers:(NSString*)username { [twitterEngineSingleton getListsForUser:username requestDelegate:self]; } - (void)requestSucceeded:(NSString*)connectionIdentifier { NSLog(@"Hello"); } @end @interface AdvancedTwitterEngine : NSObject &lt;MGTwitterEngineDelegate&gt; { MGTwitterEngine* _engine; NSMutableDictionary* _callerIds; } -(NSString*)getListsForUser:(NSString*)username requestDelegate:(id&lt;MGTwitterEngineDelegate&gt;)delegate; @end @implementation AdvancedTwitterEngine; -(void)init { if (self = [super init]) { _engine = [[MGTTwitterEngine alloc] initWithDelegate:self]; _callerIds = &lt;init&gt; } return self; } -(NSString*)getListsForUser:(NSString*)username requestDelegate:(id&lt;MGTwitterEngineDelegate&gt;)delegate { NSString* twId = [_engine getListsForUser:username]; [_callerIds setObject:controller forKey:twId]; return twId; } //-- delegate methods - (void)requestSucceeded:(NSString*)connectionIdentifier { id&lt;MGTwitterEngineDelegate&gt; dlg = [_callerIds objectForKey:connectionIdentifier]; [dlg requestSucceeded:connectionIdentifier]; } @end </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload