Skip to content

Instantly share code, notes, and snippets.

@allenlinli
Last active December 5, 2016 03:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save allenlinli/2ca3ec3abb65f82e0a0b9510cfee3b0d to your computer and use it in GitHub Desktop.
Save allenlinli/2ca3ec3abb65f82e0a0b9510cfee3b0d to your computer and use it in GitHub Desktop.
static NSInteger const maxRetryCountForFetchingTicket = 10;
- (void)_handleFetchTicketFailWithError:(NSError *)inError petID:(NSString *)inPet
{
if ([inError code] == KKInvalidSessionError) {
//error handling
return;
}
retryCount ++;
if (retryCount == maxRetryCountForFetchingTicket) {
retryCount = 0;
//retry count run out, handle error
return;
}
// _fetchPetContentWithSongID is the API call.
[self performSelector:@selector(_fetchPetContentWithPetID:) withObject:inPetID afterDelay:2.0];
}
- (void)_fetchPetContentWithSongID:(NSString *)inPetID
{
// use NSURLSession or NSURLConnection to make API call.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment