2

are there some commonly used utils or standard way to parse http-forms into key-value pairs e.g. into NSDictionary?

thanks for any help

funberry
  • 468
  • 3
  • 10
  • Could you add a bit of context to your question? what are you trying to do? Are you trying to get the values of the http form as it's rendered within a web view, or are you trying to get the values of the form *after* the user clicks "submit" to send the form data back to the server? – Michael Dautermann Dec 02 '12 at 19:10
  • send request from my iOS application to remote server and then receive x-www-from-urlencoded response – funberry Dec 06 '12 at 20:34

2 Answers2

0

I can't find any light-weight solution, but where's good Objective-C library called GCDWebServer

This is how I use it:

in Podfile

pod "GCDWebServer"

in my application

#import "GCDWebServerFunctions.h"

NSDictionary *dict = GCDWebServerParseURLEncodedForm(bodyString);
protuberian
  • 896
  • 7
  • 13
-2

Yes. NSJSONSerialization. It's exactly what you're looking for.

UPDATE:

If you need to parse application/x-www-form-urlencoded data, this answer is best. You may need to first convert the NSData to a string.

Community
  • 1
  • 1
Sam Ballantyne
  • 487
  • 6
  • 18