Created
June 3, 2013 18:53
-
-
Save fjcaetano/5700381 to your computer and use it in GitHub Desktop.
Return methods definition protocol at the and of a request using AFNetworking.
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
// | |
// AFNetworkingOperationDelegate.h | |
// | |
// Created by Flávio Caetano on 12/12/12. | |
// Copyright (c) 2012 FlávioCaetano.com. | |
// | |
#import <Foundation/Foundation.h> | |
#define COMPLETION_BLOCK(delegate) ^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON){[delegate requestDidFinish:request withResponse:response andJSON:JSON];} | |
#define ERROR_BLOCK(delegate) ^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON){[delegate requestDidFail:request withResponse:response error:error andJSON:JSON];} | |
//#define COMPLETION(delegate) ^(AFHTTPRequestOperation * operation){} | |
/** Return methods definition protocol at the and of a request using AFNetworking. | |
Defined macros: | |
- **COMPLETION_BLOCK(delegate)**: alias to the success block provided to the AFNetworking request. | |
- **ERROR_BLOCK(delegate)**: alias to the fail block providede to the AFNetworking request. | |
*/ | |
@protocol AFNetworkingOperationDelegate <NSObject> | |
/** Method called at the end of the request in case of success. | |
@param request NSURLRequest sent with the request's call. | |
@param response NSHTTPURLResponse with the request's response data. | |
@param JSON `id` with the JSON object. | |
*/ | |
- (void)requestDidFinish:(NSURLRequest *)request withResponse:(NSHTTPURLResponse *)response andJSON:(id)JSON; | |
/** Method called at the end of the request if failed. | |
@param request NSURLRequest sent with the request's call. | |
@param response NSHTTPURLResponse with the request's response data. | |
@param error NSError the occurred error. | |
@param JSON `id` with the JSON object. | |
*/ | |
- (void)requestDidFail:(NSURLRequest *)request withResponse:(NSHTTPURLResponse *)response error:(NSError *)error andJSON:(id)JSON; | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment