Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CFURLCreateStringByAddingPercentEscapes is deprecated in iOS 9, how do I use "stringByAddingPercentEncodingWithAllowedCharacters"

I have the following code:

    return (NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)string, NULL, CFSTR(";:@&=+$,/?%#[]"), kCFStringEncodingUTF8);

Xcode says it is deprecated in iOS 9. So, how do I use stringByAddingPercentEncodingWithAllowedCharacters ?

Thanks!

like image 752
ikevin8me Avatar asked Mar 04 '16 08:03

ikevin8me


1 Answers

try this

NSString *value = @"<url>";
value = [value stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
like image 129
techloverr Avatar answered Oct 05 '22 10:10

techloverr