Send Email iOSThe following snippet shows how to parse the Http QueryString and extract the parameters (key/value pairs) as a dictionary object.

This is useful for working with iPhone/iPad applications that send or receive http requests.

<!>

  1.  (NSDictionary *)parseQueryString:(NSString *)query {
  2.     NSMutableDictionary *dict = [[[NSMutableDictionary alloc] initWithCapacity:6] autorelease];
  3.     NSArray *pairs = [query componentsSeparatedByString:@"&"];
  4.    
  5.     for (NSString *pair in pairs) {
  6.         NSArray *elements = [pair componentsSeparatedByString:@"="];
  7.         NSString *key = [[elements objectAtIndex:0] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  8.         NSString *val = [[elements objectAtIndex:1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  9.        
  10.         [dict setObject:val forKey:key];
  11.     }
  12.     return dict;
  13. }