diff --git a/AFNetworking/AFHTTPClient.h b/AFNetworking/AFHTTPClient.h index 85427d0..18bd29c 100644 --- a/AFNetworking/AFHTTPClient.h +++ b/AFNetworking/AFHTTPClient.h @@ -227,25 +227,27 @@ typedef enum { parameters:(NSDictionary *)parameters constructingBodyWithBlock:(void (^)(id formData))block; - -///-------------------------------- -/// @name Enqueuing HTTP Operations -///-------------------------------- +///------------------------------- +/// @name Creating HTTP Operations +///------------------------------- /** - Creates and enqueues an `AFHTTPRequestOperation` to the HTTP client's operation queue. + Creates an `AFHTTPRequestOperation` In order to determine what kind of operation is enqueued, each registered subclass conforming to the `AFHTTPClient` protocol is consulted in turn to see if it can handle the specific request. The first class to return `YES` when sent a `canProcessRequest:` message is used to generate an operation using `HTTPRequestOperationWithRequest:success:failure:`. - + @param request The request object to be loaded asynchronously during execution of the operation. @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes a single argument, which is an object created from the response data of request. @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the resonse data. This block has no return value and takes a single argument, which is the `NSError` object describing the network or parsing error that occurred. - - @see `AFHTTPClientOperation` */ -- (void)enqueueHTTPRequestOperationWithRequest:(NSURLRequest *)request - success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success - failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; +- (AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)request + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; + +///---------------------------------------- +/// @name Managing Enqueued HTTP Operations +///---------------------------------------- + /** Enqueues an `AFHTTPRequestOperation` to the HTTP client's operation queue. @@ -253,10 +255,6 @@ typedef enum { */ - (void)enqueueHTTPRequestOperation:(AFHTTPRequestOperation *)operation; -///--------------------------------- -/// @name Cancelling HTTP Operations -///--------------------------------- - /** Cancels all operations in the HTTP client's operation queue that match the specified HTTP method and URL. diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index c791f2b..ba1f938 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -313,9 +313,9 @@ static NSString * AFPropertyListStringFromParameters(NSDictionary *parameters) { return request; } -- (void)enqueueHTTPRequestOperationWithRequest:(NSURLRequest *)urlRequest - success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success - failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure +- (AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)urlRequest + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure { AFHTTPRequestOperation *operation = nil; NSString *className = nil; @@ -333,7 +333,7 @@ static NSString * AFPropertyListStringFromParameters(NSDictionary *parameters) { [operation setCompletionBlockWithSuccess:success failure:failure]; - [self enqueueHTTPRequestOperation:operation]; + return operation; } - (void)enqueueHTTPRequestOperation:(AFHTTPRequestOperation *)operation { @@ -356,7 +356,8 @@ static NSString * AFPropertyListStringFromParameters(NSDictionary *parameters) { failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure { NSURLRequest *request = [self requestWithMethod:@"GET" path:path parameters:parameters]; - [self enqueueHTTPRequestOperationWithRequest:request success:success failure:failure]; + AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:success failure:failure]; + [self enqueueHTTPRequestOperation:operation]; } - (void)postPath:(NSString *)path @@ -365,7 +366,8 @@ static NSString * AFPropertyListStringFromParameters(NSDictionary *parameters) { failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure { NSURLRequest *request = [self requestWithMethod:@"POST" path:path parameters:parameters]; - [self enqueueHTTPRequestOperationWithRequest:request success:success failure:failure]; + AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:success failure:failure]; + [self enqueueHTTPRequestOperation:operation]; } - (void)putPath:(NSString *)path @@ -374,7 +376,8 @@ static NSString * AFPropertyListStringFromParameters(NSDictionary *parameters) { failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure { NSURLRequest *request = [self requestWithMethod:@"PUT" path:path parameters:parameters]; - [self enqueueHTTPRequestOperationWithRequest:request success:success failure:failure]; + AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:success failure:failure]; + [self enqueueHTTPRequestOperation:operation]; } - (void)deletePath:(NSString *)path @@ -383,7 +386,8 @@ static NSString * AFPropertyListStringFromParameters(NSDictionary *parameters) { failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure { NSURLRequest *request = [self requestWithMethod:@"DELETE" path:path parameters:parameters]; - [self enqueueHTTPRequestOperationWithRequest:request success:success failure:failure]; + AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:success failure:failure]; + [self enqueueHTTPRequestOperation:operation]; } @end