Encoding the special charecters of a NSString in Objective-c

NSString *unescaped = @"http://www";
NSString *escapedString = (NSString *)CFURLCreateStringByAddingPercentEscapes(
    NULL,
   (CFStringRef)unescaped,
    NULL,
    CFSTR("!*'();:@&=+$,/?%#[]"),
    kCFStringEncodingUTF8);

NSLog(@"escapedString: %@",escapedString);

NSLog output:

escapedString: http%3A%2F%2Fwww

Under ARC one alternative is:

NSString *escapedString = (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(
    NULL,
   (__bridge CFStringRef) unescaped,
    NULL,
    CFSTR("!*'();:@&=+$,/?%#[]"),
    kCFStringEncodingUTF8));