NSString method to percent escape '&' for URL

cocoa-touch, encoding, nsstring

Solution

Ampersands won't be processed by that method because they're legal characters in a URL. You should probably pre-process particularly problematic pieces, piecemeal, prior to this call.

Problem

Which NSString encoding method will percent escape the ampersand (&) character correctly into `%26`? ``` stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding ``` gets the spaces (%20) and other baddies but ignores ampersands!?!

Original source