Skip to content

Instantly share code, notes, and snippets.

@fisherds
Created August 4, 2014 02:34
Show Gist options
  • Select an option

  • Save fisherds/9b82adc4a7044b5e3a65 to your computer and use it in GitHub Desktop.

Select an option

Save fisherds/9b82adc4a7044b5e3a65 to your computer and use it in GitHub Desktop.
Endpoints iOS function used to update a Movie Quote
// Within RHDetailViewController.m
#pragma mark - Endpoints
- (void) _updateQuote {
// Make a query object
// Use the service to execute the query
// Use a callback block to handle the response
GTLQueryMoviequotes* query = [GTLQueryMoviequotes queryForMoviequoteInsertWithObject:self.movieQuote];
if (self.isLocalHostTesting) {
query.JSON = self.movieQuote.JSON;
query.bodyObject = nil;
}
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
[self.service executeQuery:query
completionHandler:^(GTLServiceTicket *ticket,
GTLMoviequotesMovieQuote* returnedMovieQuote,
NSError *error) {
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
if (error != nil) {
UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Error doing update"
message:error.localizedDescription
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
return;
}
// Do nothing. Quote was already updated locally.
}];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment