Parse an HTTP Query String into a Dictionary
Parse an HTTP Query String into a Dictionary
- Subject: Parse an HTTP Query String into a Dictionary
- From: Jerry Krinock <email@hidden>
- Date: Thu, 7 Aug 2008 17:55:01 -0700
Before I write the implementation for this NSString category method,
I'd like to know if it's already already available somewhere:
@interface NSString (URIQuery)
/*!
@method queryDictionary
@abstract Assuming that the receiver is a query string of
key=value pairs,
of the form "key0=value0&key1=value1&...", with keys and values
percent-escape
encoded per RFC 2396, returns a dictionary of the keys and values.
@discussion If I recall correctly, ";" can also be used in place of
the "&" delimiter
*/
- queryDictionary ;
@end
It seems like it would not be too difficult to implement using
NSScanner and CFURLCreateStringByReplacingPercentEscapes(), but I've
done enough things that "seemed like it would not be too difficult" to
know that tested code is always preferable.
Thanks,
Jerry
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden