Skip to content

Instantly share code, notes, and snippets.

@almassapargali
Created July 3, 2014 23:13
Show Gist options
  • Save almassapargali/f31108c172b5dc51ce71 to your computer and use it in GitHub Desktop.
Save almassapargali/f31108c172b5dc51ce71 to your computer and use it in GitHub Desktop.
add parameters too all requests
#import "AFURLRequestSerialization.h"
@interface DefaultParamsSerializer : AFHTTPRequestSerializer
@end
#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