Skip to content

Instantly share code, notes, and snippets.

@augustjoki
Last active November 5, 2015 00:48
Show Gist options
  • Save augustjoki/808958e8ab0836394e78 to your computer and use it in GitHub Desktop.
Save augustjoki/808958e8ab0836394e78 to your computer and use it in GitHub Desktop.
block variables
__weak typeof(self) weakSelf = self;
AFJSONRequestOperation *operation =
[AFJSONRequestOperation JSONRequestOperationWithRequest:request
success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
NSDictionary *jsonDict = (NSDictionary *) JSON;
// this is the array that stores the JSON response
NSArray *csvFiles = [jsonDict objectForKey:@"csv_files"];
[weakSelf doSomethingWithTheArray:csvFiles];
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) {
NSLog(@"Request Failure Because %@",[error userInfo]);
}];
[operation start];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment