-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNSDictionary+http.m
More file actions
33 lines (26 loc) · 864 Bytes
/
NSDictionary+http.m
File metadata and controls
33 lines (26 loc) · 864 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//
// NSDictionary+http.m
// Gisties
//
// Created by Michael Schrag on 2/14/09.
// Copyright 2009 m Dimension Technology. All rights reserved.
//
#import "NSDictionary+http.h"
@implementation NSDictionary (http)
- (NSString *)formEncoded {
NSMutableString *formEncoded = [NSMutableString stringWithCapacity:256];
BOOL started = NO;
NSString *key;
NSEnumerator *keys = [self keyEnumerator];
while ((key = [keys nextObject]) != nil) {
if (started) {
[formEncoded appendString: @"&"];
}
NSString *escapedKey = [key stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *escapedValue = [[self objectForKey:key] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[formEncoded appendString: [NSString stringWithFormat:@"%@=%@", escapedKey, escapedValue]];
started = YES;
}
return formEncoded;
}
@end