Created
March 15, 2012 13:13
-
-
Save Dimillian/2044138 to your computer and use it in GitHub Desktop.
Blocks REST
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
{ | |
MSheaderSeeenViewCell *clickedCell = (MSheaderSeeenViewCell *)[[sender superview]superview]; | |
[clickedCell.indicator startAnimating]; | |
[sender setHidden:YES]; | |
MSMovie *movie = [movies objectAtIndex:[self.tableView indexPathForCell:clickedCell].row]; | |
MSRESTRequest *getInfoRequest = [[MSRESTRequest alloc]initWithMethod:@"GET" | |
ressource:@"movies" | |
parameters:[NSArray arrayWithObject: | |
[NSString stringWithFormat:@"movie_id=%@", movie.udid]] | |
shouldEscapeParameters:YES]; | |
[getInfoRequest executeBlockRequest:^(NSJSONSerialization *json, MSJSonError *error){ | |
if (!error) { | |
MSRESTRequest *putMovieRequest = [[MSRESTRequest alloc]initWithMethod:@"PUT" | |
ressource:@"myseeen" | |
parameters:[NSArray arrayWithObject:[ | |
NSString stringWithFormat:@"movie_id=%@", movie.udid]] | |
shouldEscapeParameters:YES]; | |
[putMovieRequest executeBlockRequest:^(NSJSONSerialization *json, MSJSonError *error){ | |
[clickedCell.indicator stopAnimating]; | |
if (!error) { | |
[sender setHidden:YES]; | |
[[NSNotificationCenter defaultCenter]postNotificationName:USER_UPDATED_MYSEEEN object:nil]; | |
} | |
else { | |
[sender setHidden:NO]; | |
} | |
}]; | |
} | |
}]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment