Skip to content

Instantly share code, notes, and snippets.

@pwgustafson
Created June 13, 2014 22:38
Show Gist options
  • Save pwgustafson/05c1da97ae77e7ec9fe3 to your computer and use it in GitHub Desktop.
Save pwgustafson/05c1da97ae77e7ec9fe3 to your computer and use it in GitHub Desktop.
//NSString *string = [NSString stringWithFormat:@"%@weather.php?format=json", BaseURLString];
NSString *string = [NSString stringWithFormat:@"%@sessions", BaseURLString];
NSURL *url = [NSURL URLWithString:string];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
// 2
NSDictionary *params = @{@"email": email,
@"password": password};
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
operation.responseSerializer = [AFJSONResponseSerializer serializer];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
// 3
//self.weather = (NSDictionary *)responseObject;
//self.title = @"JSON Retrieved";
//[self.tableView reloadData];
NSLog(@"%@", responseObject);
//[self popViewControllerAnimated:YES];
[self.navigationController popViewControllerAnimated:YES];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
// 4
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error Retrieving Weather"
message:[error localizedDescription]
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alertView show];
}];
// 5
[operation start];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment