Skip to content

Instantly share code, notes, and snippets.

@Dimillian
Created March 15, 2012 13:13
Show Gist options
  • Save Dimillian/2044138 to your computer and use it in GitHub Desktop.
Save Dimillian/2044138 to your computer and use it in GitHub Desktop.
Blocks REST
{
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