在iOS 9中不推荐使用CFURLCreateStringByAddingPercentEscapes,如何使用“stringByAddingPercentEncodingWithAllowedCharacters”" [英] CFURLCreateStringByAddingPercentEscapes is deprecated in iOS 9, how do I use "stringByAddingPercentEncodingWithAllowedCharacters"

查看:2643
本文介绍了在iOS 9中不推荐使用CFURLCreateStringByAddingPercentEscapes,如何使用“stringByAddingPercentEncodingWithAllowedCharacters”"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码:

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

Xcode表示它在iOS 9中已弃用。那么,我该如何使用stringByAddingPercentEncodingWithAllowedCharacters?

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

谢谢!

推荐答案

试试这个

NSString *value = @"<url>";
value = [value stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];

这篇关于在iOS 9中不推荐使用CFURLCreateStringByAddingPercentEscapes,如何使用“stringByAddingPercentEncodingWithAllowedCharacters”&quot;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆