Created
July 3, 2014 23:13
-
-
Save almassapargali/f31108c172b5dc51ce71 to your computer and use it in GitHub Desktop.
add parameters too all requests
This file contains 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
#import "AFURLRequestSerialization.h" | |
@interface DefaultParamsSerializer : AFHTTPRequestSerializer | |
@end |
This file contains 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
#import "DefaultParamsSerializer.h" | |
@implementation DefaultParamsSerializer | |
- (NSMutableURLRequest *)requestWithMethod:(NSString *)method URLString:(NSString *)URLString parameters:(id)parameters error:(NSError *__autoreleasing *)error | |
{ | |
if (parameters) { | |
if ([parameters isKindOfClass:[NSDictionary class]]) { | |
NSMutableDictionary *mParams = [parameters mutableCopy]; | |
mParams[@"key"] = @"value"; | |
parameters = [mParams copy]; | |
} | |
} else { | |
parameters = @{@"key": @"value"}; | |
} | |
return [super requestWithMethod:method URLString:URLString parameters:parameters error:error]; | |
} | |
// override these too if you use them | |
//- (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method URLString:(NSString *)URLString parameters:(NSDictionary *)parameters constructingBodyWithBlock:(void (^)(id<AFMultipartFormData>))block error:(NSError **)error | |
//- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request withParameters:(id)parameters error:(NSError **)error | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment