#import "NSString+SSURLEncoding.h" @implementation NSString (SSURLEncoding) - (NSString*)URLEncodedString { NSString* result = (NSString *)CFBridgingRelease( CFURLCreateStringByAddingPercentEscapes( kCFAllocatorDefault, (CFStringRef)self, CFSTR("#%"), // don't escape these NULL, // allow escaping these kCFStringEncodingUTF8 ) ); // we may have a URL with more than one '#' now - which iOS doesn't allow, so escape all but the first one NSArray *parts = [result componentsSeparatedByString:@"#"]; NSString *finalResult = parts[0]; for (int i=1; i