NSString+URLEncoding.h
#import <Foundation/Foundation.h> @interface NSString(URLEncoding) - (NSString *)urlEncodeString; @end
NSString+URLEncoding.m
#import "NSString+URLEncoding.h" @implementation NSString(URLEncoding) - (NSString *)urlEncodeString { NSString *result = (NSString *)CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)self, NULL, (CFStringRef)@";/?:@&=$+{}<>,", kCFStringEncodingUTF8); return [result autorelease]; } @end