title: iOS AWS S3 Upload How To Retry Failed or Faulted Tasks?
body: <p>I'm utilizing the iOS AWS SDK's batch upload <code>[AWSTask taskForCompletionOfAllTasks:tasks]</code> The <code>tasks</code> array is an array of <code>AWSTask *task = [self.transferManager upload:uploadRequest];</code> objects. Once the upload is complete I can enumerate through the array to check to see if all the tasks were successful or not.  However, I can't seem to figure out how to retry a failed or faulted task. If I pass an array of failed tasks to <code>taskForCompletionOfAllTasks</code> it doesn't do anything with those tasks?</p>
  
  <p>The <a href="http://docs.aws.amazon.com/mobile/sdkforios/developerguide/s3transfermanager.html#upload-files-from-the-console" rel="nofollow">iOS AWS docs</a> it doesn't mention anything about retrying on failed or faulted task.  Yes, there is the <code>AWSServiceConfiguration.maxRetryCount</code> but that doesn't solve the issue with retrying faulted or failed tasks after that count as been exceeded.  Also the <a href="https://github.com/awslabs/aws-sdk-ios-samples" rel="nofollow">iOS AWS Examples</a> don't show anything in regards to this either.</p>
  
  <pre><code>- (void)performS3UploadWithRequest:(NSArray *)tasks withRetryCount:(int)retryCount
  {
  
      if (retryCount == 0) {
          alert = [[UIAlertView alloc] initWithTitle:@"Failed to Upload Content"
                                             message:@"It appears we are having issues uploading your card information."
                                            delegate:self cancelButtonTitle:nil
                                   otherButtonTitles:@"Retry Upload", @"Retry Later", @"Cancel Order", nil];
          [alert show];
      } else {
          [[AWSTask taskForCompletionOfAllTasks:tasks] continueWithExecutor:[AWSExecutor mainThreadExecutor] withBlock:^id(AWSTask *task) {
              NSMutableArray *faultedTasks = [NSMutableArray new];
              for (AWSTask *finishedTask in tasks) {
                  if (finishedTask.cancelled || finishedTask.faulted) {
                      [faultedTasks addObject:finishedTask];
                  }
              }
  
              if (faultedTasks.count &gt; 0) {
                  [self performS3UploadWithRequest:faultedTasks withRetryCount:retryCount-1];
              } else {
                  [[NSNotificationCenter defaultCenter] postNotificationName:kWHNotificationUploadDone object:self userInfo:nil];
              }
              return nil;
          }];
      }
  }
  </code></pre>