-1

Possible Duplicate:
String won't url encode in iOS

I am using ASIHttpRequest to send http request to my server. In Jquery I can construct a dictionary and just send the dictionary to jquery's ajax method, the Jquery will do the url encode things.

It looks like ASIHttp lacks of such API? Which API I can use to encode a dictionary(or other simple method) to a url encoded string?

Community
  • 1
  • 1
Bin Chen
  • 61,507
  • 53
  • 142
  • 183

1 Answers1

1

You can use

- (NSString *)stringByAddingPercentEscapesUsingEncoding:(NSStringEncoding)enc;

Example:

NSString* string = @"Hello, World";
NSString* encodedString = [string stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];