//swift
let customAllowedSet = NSCharacterSet(charactersIn:"!*'();:@&=+$,/?%#[]").inverted
let infoValue = str.addingPercentEncoding(withAllowedCharacters: customAllowedSet)!
//oc
NSString *encodedString = (NSString *)CFURLCreateStringByAddingPercentEscapes(
NULL,
(CFStringRef)unencodedString,
NULL,
(CFStringRef)@"!*'();:@&=+$,/?%#[]",
kCFStringEncodingUTF8 );