Skip to content

Instantly share code, notes, and snippets.

@ToQoz
Last active January 2, 2016 06:59
Show Gist options
  • Save ToQoz/8267396 to your computer and use it in GitHub Desktop.
Save ToQoz/8267396 to your computer and use it in GitHub Desktop.
// typedef void (^TQAPIHTTPRequestSuccessHandler)(AFHTTPRequestOperation *operation, id responseObject);
// typedef void (^TQAPIHTTPRequestFailureHandler)(AFHTTPRequestOperation *operation, NSError *error);
NSString *path = <#path#>;
NSDictionary *params = <#params#>;
// ↓ OR define custom type and use it. e.g. TQAPIHTTPRequestSuccessHandler successHandler = ...
void (^successHandler)(AFHTTPRequestOperation *operation, id responseObject) = ^(AFHTTPRequestOperation *operation, id responseObject) {
if (block) { block(responseObject, nil); }
};
// ↓ OR define custom type and use it. e.g. TQAPIHTTPRequestFailureHandler failureHandler = ...
void (^failureHandler)(AFHTTPRequestOperation *operation, NSError *error) = ^(AFHTTPRequestOperation *operation, NSError *error) {
if (block) { block(nil, error); }
};
[self <#httpMethod#>Path:path
parameters:params
success:successHandler
failure:failureHandler];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment