Created
August 4, 2014 02:34
-
-
Save fisherds/9b82adc4a7044b5e3a65 to your computer and use it in GitHub Desktop.
Endpoints iOS function used to update a Movie Quote
This file contains hidden or 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
| // 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