Created
December 3, 2013 07:24
-
-
Save axldyb/7765269 to your computer and use it in GitHub Desktop.
Method retrying AFNetworking request n number of times. Not a perfect implementation, but this is just for saving the idea.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)downloadFileRetryingNumberOfTimes:(NSUInteger)numberOfTimes | |
success:(void (^)(id responseObject))success | |
failure:(void (^)(NSError *error))failure | |
{ | |
if (numberOfTimes <= 0) { | |
if (failure) { | |
NSError *error = ...; | |
failure(error); | |
} | |
} else { | |
[self getPath:@"/path" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) { | |
if (success) { | |
success(...); | |
} | |
} failure:^(AFHTTPRequestOperation *operation, NSError *error) { | |
[self downloadFileRetryingNumberOfTimes:numberOfTimes - 1 success:success failure:failure]; | |
}]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment