Skip to content

Commit

Permalink
精简代码
Browse files Browse the repository at this point in the history
  • Loading branch information
songwentong committed Jan 17, 2015
1 parent 6d9b138 commit 6533ed9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 62 deletions.
20 changes: 10 additions & 10 deletions WTRequestCenter/WTRequestCenter/WTRequestCenter.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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) {
Expand All @@ -458,7 +458,7 @@ +(WTURLRequestOperation*)testdoURLRequest:(NSURLRequest*)request
}];
[[self sharedQueue] addOperation:operation];
return operation;
#pragma clang diagnostic pop
//#pragma clang diagnostic pop

}

Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
17 changes: 5 additions & 12 deletions WTRequestCenter/WTRequestCenter/WTURLRequestSerialization.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ extern NSTimeInterval const WTURLRequestSerializationTimeoutTimeInterval;
GET请求
*/
+(NSMutableURLRequest*)GETRequestWithURL:(NSString*)url
parameters:(NSDictionary*)parameters;

//实例的GET方法
-(NSMutableURLRequest*)GETRequestWithURL:(NSString*)url
parameters:(NSDictionary*)parameters;
Expand All @@ -49,8 +48,7 @@ extern NSTimeInterval const WTURLRequestSerializationTimeoutTimeInterval;
POST请求
*/
+(NSMutableURLRequest*)POSTRequestWithURL:(NSString*)url
parameters:(NSDictionary*)parameters;

//实例的POST方法
-(NSMutableURLRequest*)POSTRequestWithURL:(NSString*)url
parameters:(NSDictionary*)parameters;
Expand All @@ -59,7 +57,8 @@ extern NSTimeInterval const WTURLRequestSerializationTimeoutTimeInterval;
支持数据上传的POST请求
*/
+(NSMutableURLRequest*)POSTRequestWithURL:(NSString*)url

-(NSMutableURLRequest*)POSTRequestWithURL:(NSString*)url
parameters:(NSDictionary*)parameters
constructingBodyWithBlock:(void (^)(id <WTMultipartFormData> formData))block;

Expand All @@ -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;




Expand Down
40 changes: 0 additions & 40 deletions WTRequestCenter/WTRequestCenter/WTURLRequestSerialization.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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
{
Expand All @@ -242,16 +228,6 @@ -(NSMutableURLRequest*)POSTRequestWithURL:(NSString*)url
return request;
}

+(NSMutableURLRequest*)POSTRequestWithURL:(NSString*)url
parameters:(NSDictionary*)parameters
constructingBodyWithBlock:(void (^)(id <WTMultipartFormData> formData))block
{


return [[self sharedRequestSerialization] POSTRequestWithURL:url
parameters:parameters
constructingBodyWithBlock:block];
}

-(NSMutableURLRequest*)POSTRequestWithURL:(NSString*)url
parameters:(NSDictionary*)parameters
Expand Down Expand Up @@ -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
{
Expand All @@ -331,16 +301,6 @@ -(NSMutableURLRequest*)PUTRequestWithURL:(NSString*)url
}


+(NSMutableURLRequest*)HEADRequestWithURL:(NSString*)url
parameters:(NSDictionary*)parameters
{
NSMutableURLRequest *request = nil;



return request;
}



+(NSString*)stringFromDate:(NSDate*)date
Expand Down

0 comments on commit 6533ed9

Please sign in to comment.