Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You shouldn't keep operations that failed in queue, but use the queue for serial fetching data, and stop queueing if the operation fails :</p> <pre><code>@implementation DataAdapter // ... -(void)setup{ // weak reference to self to avoid retain cycle __weak DataAdapter* selfRef= self; // create a block that will run inside the operation queue void(^pullCountriesBlock)(void)= ^{ [[DownloadManager instance] fetchAllCountriesWithCompletionBlock:^(Result* result){ if(result.successful){ // on success [selfRef didFetchDataForAction:action]; }else{ // on failure [selfRef failedToFetchDataForAction:action]; } }; self.actions= [NSMutableArray new]; [self.actions addObject:[DownloadAction actionWithBlock:pullCountriesBlock]; // add other actions // ... [self fetchData]; } } -(void)fetchData{ if(self.currentActionIndex &gt;= self.actions.count){ [self finishedFetchingData]; return; } [self fetchDataForAction: self.actions[self.currentActionIndex] ]; } -(void)fetchDataForAction:(DownloadAction*)action [self.myOperationQueueImplementation enqueueOperationWithBlock:action.block]; } </code></pre> <p>If the download is successful, just enqueue the next action(increment the currentActionIndex and call <code>fetchData</code>). If it fails, you can act accordingly. What I'd do is start listening to interesting NSNotificationCenter events before calling fetchData the first time. You could listen to UserDidLogInNotification or any other that may allow the queue to continue running the downloads.</p>
 

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