Trying to encode URL parameters on Mac or iPhone? Frustrated because NSString stringByAddingPercentEscapesUsingEncoding encodes non-URL characters but leaves the reserved characters (like slash / and ampersand &) alone? “Apparently” this is a “bug” apple is aware of, but they haven’t done anything about it yet, and so, here is a solution that actually works.

Try this:

  NSString * encodedString = (NSString *)CFURLCreateStringByAddingPercentEscapes(
 kCFStringEncodingUTF8 );

As an example, @”‘Decoded data!’/” will become “”.

Obviously you would use this, not on the full URL, but just on the parameters.