From 6533ed9cce04416281c501a9939023e6c9f05141 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=8B=E6=96=87=E9=80=9A?= <275712575@qq.com> Date: Sat, 17 Jan 2015 11:44:06 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B2=BE=E7=AE=80=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WTRequestCenter/WTRequestCenter.m | 20 +++++----- .../WTURLRequestSerialization.h | 17 +++----- .../WTURLRequestSerialization.m | 40 ------------------- 3 files changed, 15 insertions(+), 62 deletions(-) diff --git a/WTRequestCenter/WTRequestCenter/WTRequestCenter.m b/WTRequestCenter/WTRequestCenter/WTRequestCenter.m index e6bebc2..93348e1 100644 --- a/WTRequestCenter/WTRequestCenter/WTRequestCenter.m +++ b/WTRequestCenter/WTRequestCenter/WTRequestCenter.m @@ -171,7 +171,7 @@ +(NSURLRequest*)getWithURL:(NSString*)url finished:(WTRequestFinishedBlock)finished failed:(WTRequestFailedBlock)failed { - NSURLRequest *request = [WTURLRequestSerialization GETRequestWithURL:url parameters:parameters]; + NSURLRequest *request = [[WTURLRequestSerialization sharedRequestSerialization] GETRequestWithURL:url parameters:parameters]; [self doURLRequest:request option:option finished:finished failed:failed]; @@ -187,7 +187,7 @@ +(NSURLRequest*)postWithURL:(NSString*)url finished:(WTRequestFinishedBlock)finished failed:(WTRequestFailedBlock)failed { - NSURLRequest *request = [WTURLRequestSerialization POSTRequestWithURL:url parameters:parameters]; + NSURLRequest *request = [[WTURLRequestSerialization sharedRequestSerialization] POSTRequestWithURL:url parameters:parameters]; [self doURLRequest:request finished:finished failed:failed]; return request; } @@ -201,7 +201,7 @@ +(NSURLRequest*)postWithURL:(NSString*)url finished:(WTRequestFinishedBlock)finished failed:(WTRequestFailedBlock)failed { - NSURLRequest *request = [WTURLRequestSerialization POSTRequestWithURL:url parameters:parameters constructingBodyWithBlock:block]; + NSURLRequest *request = [[WTURLRequestSerialization sharedRequestSerialization] POSTRequestWithURL:url parameters:parameters constructingBodyWithBlock:block]; [self doURLRequest:request finished:finished failed:failed]; return request; } @@ -212,7 +212,7 @@ +(NSURLRequest*)putWithURL:(NSString*)url finished:(WTRequestFinishedBlock)finished failed:(WTRequestFailedBlock)failed { - NSURLRequest *request = [WTURLRequestSerialization PUTRequestWithURL:url parameters:parameters]; + NSURLRequest *request = [[WTURLRequestSerialization sharedRequestSerialization] PUTRequestWithURL:url parameters:parameters]; [self doURLRequest:request finished:finished failed:failed]; return request; } @@ -436,9 +436,9 @@ +(WTURLRequestOperation*)testdoURLRequest:(NSURLRequest*)request finished:(WTRequestFinishedBlock)finished failed:(WTRequestFailedBlock)failed { -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Warc-retain-cycles" -#pragma clang diagnostic ignored "-Wgnu" +//#pragma clang diagnostic push +//#pragma clang diagnostic ignored "-Warc-retain-cycles" +//#pragma clang diagnostic ignored "-Wgnu" WTURLRequestOperation *operation = nil; operation = [[WTURLRequestOperation alloc] initWithRequest:request]; if (progress) { @@ -458,7 +458,7 @@ +(WTURLRequestOperation*)testdoURLRequest:(NSURLRequest*)request }]; [[self sharedQueue] addOperation:operation]; return operation; -#pragma clang diagnostic pop +//#pragma clang diagnostic pop } @@ -573,7 +573,7 @@ +(WTURLRequestOperation*)testGetWithURL:(NSString*)url finished:(WTRequestFinishedBlock)finished failed:(WTRequestFailedBlock)failed { - NSURLRequest *request = [WTURLRequestSerialization GETRequestWithURL:url parameters:parameters]; + NSURLRequest *request = [[WTURLRequestSerialization sharedRequestSerialization]GETRequestWithURL:url parameters:parameters]; WTURLRequestOperation *operation = [self testdoURLRequest:request option:option progress:progress finished:finished failed:failed]; return operation; } @@ -585,7 +585,7 @@ +(WTURLRequestOperation*)testPOSTWithURL:(NSString*)url finished:(WTRequestFinishedBlock)finished failed:(WTRequestFailedBlock)failed { - NSURLRequest *request = [WTURLRequestSerialization POSTRequestWithURL:url parameters:parameters]; + NSURLRequest *request = [[WTURLRequestSerialization sharedRequestSerialization] POSTRequestWithURL:url parameters:parameters]; WTURLRequestOperation *operation = [self testdoURLRequest:request progress:nil finished:finished failed:failed]; return operation; } diff --git a/WTRequestCenter/WTRequestCenter/WTURLRequestSerialization.h b/WTRequestCenter/WTRequestCenter/WTURLRequestSerialization.h index 5359242..2d4b2b2 100644 --- a/WTRequestCenter/WTRequestCenter/WTURLRequestSerialization.h +++ b/WTRequestCenter/WTRequestCenter/WTURLRequestSerialization.h @@ -39,8 +39,7 @@ extern NSTimeInterval const WTURLRequestSerializationTimeoutTimeInterval; GET请求 */ -+(NSMutableURLRequest*)GETRequestWithURL:(NSString*)url - parameters:(NSDictionary*)parameters; + //实例的GET方法 -(NSMutableURLRequest*)GETRequestWithURL:(NSString*)url parameters:(NSDictionary*)parameters; @@ -49,8 +48,7 @@ extern NSTimeInterval const WTURLRequestSerializationTimeoutTimeInterval; POST请求 */ -+(NSMutableURLRequest*)POSTRequestWithURL:(NSString*)url - parameters:(NSDictionary*)parameters; + //实例的POST方法 -(NSMutableURLRequest*)POSTRequestWithURL:(NSString*)url parameters:(NSDictionary*)parameters; @@ -59,7 +57,8 @@ extern NSTimeInterval const WTURLRequestSerializationTimeoutTimeInterval; 支持数据上传的POST请求 */ -+(NSMutableURLRequest*)POSTRequestWithURL:(NSString*)url + +-(NSMutableURLRequest*)POSTRequestWithURL:(NSString*)url parameters:(NSDictionary*)parameters constructingBodyWithBlock:(void (^)(id formData))block; @@ -68,14 +67,8 @@ extern NSTimeInterval const WTURLRequestSerializationTimeoutTimeInterval; /*! PUT请求 */ -+(NSMutableURLRequest*)PUTRequestWithURL:(NSString*)url +-(NSMutableURLRequest*)PUTRequestWithURL:(NSString*)url parameters:(NSDictionary*)parameters; -/*! - To Do head请求 - */ -+(NSMutableURLRequest*)HEADRequestWithURL:(NSString*)url - parameters:(NSDictionary*)parameters; - diff --git a/WTRequestCenter/WTRequestCenter/WTURLRequestSerialization.m b/WTRequestCenter/WTRequestCenter/WTURLRequestSerialization.m index 1d12e23..8654830 100644 --- a/WTRequestCenter/WTRequestCenter/WTURLRequestSerialization.m +++ b/WTRequestCenter/WTRequestCenter/WTURLRequestSerialization.m @@ -173,12 +173,6 @@ -(NSString*)stringFromParameters:(NSDictionary*)parameters } #pragma mark - 请求的生成 -+(NSMutableURLRequest*)GETRequestWithURL:(NSString*)url - parameters:(NSDictionary*)parameters -{ - return [[self sharedRequestSerialization] GETRequestWithURL:url - parameters:parameters]; -} -(NSMutableURLRequest*)GETRequestWithURL:(NSString*)url parameters:(NSDictionary*)parameters { @@ -210,14 +204,6 @@ -(NSMutableURLRequest*)GETRequestWithURL:(NSString*)url return request; } -+(NSMutableURLRequest*)POSTRequestWithURL:(NSString*)url - parameters:(NSDictionary*)parameters -{ - - - return [[self sharedRequestSerialization] POSTRequestWithURL:url - parameters:parameters]; -} -(NSMutableURLRequest*)POSTRequestWithURL:(NSString*)url parameters:(NSDictionary*)parameters { @@ -242,16 +228,6 @@ -(NSMutableURLRequest*)POSTRequestWithURL:(NSString*)url return request; } -+(NSMutableURLRequest*)POSTRequestWithURL:(NSString*)url - parameters:(NSDictionary*)parameters - constructingBodyWithBlock:(void (^)(id formData))block -{ - - - return [[self sharedRequestSerialization] POSTRequestWithURL:url - parameters:parameters - constructingBodyWithBlock:block]; -} -(NSMutableURLRequest*)POSTRequestWithURL:(NSString*)url parameters:(NSDictionary*)parameters @@ -310,12 +286,6 @@ -(NSMutableURLRequest*)POSTRequestWithURL:(NSString*)url return [formData requestByFinalizingMultipartFormData]; } -+(NSMutableURLRequest*)PUTRequestWithURL:(NSString*)url - parameters:(NSDictionary*)parameters -{ - return [[self sharedRequestSerialization] PUTRequestWithURL:url - parameters:parameters]; -} -(NSMutableURLRequest*)PUTRequestWithURL:(NSString*)url parameters:(NSDictionary*)parameters { @@ -331,16 +301,6 @@ -(NSMutableURLRequest*)PUTRequestWithURL:(NSString*)url } -+(NSMutableURLRequest*)HEADRequestWithURL:(NSString*)url - parameters:(NSDictionary*)parameters -{ - NSMutableURLRequest *request = nil; - - - - return request; -} - +(NSString*)stringFromDate:(NSDate*)date