不推荐使用CFURLCreateStringByAddingPercentEscapes。替换?

时间:2016-05-28 07:12:54

标签: objective-c gdata cfurl-encoding

这是我的代码

CFStringRef escapedStr;

  escapedStr = CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
                                                       originalString,
                                                       leaveUnescaped,
                                                       kCharsToForceEscape,
                                                       kCFStringEncodingUTF8);

错误是:

  

在ios 9.0中不推荐使用CFURLCreateStringByAddingPercentEscapes   始终使用的stringByAddingPercentEncodingWithAllowedCharacters   推荐的UTF-8设置。

有人可以帮助我们在上面的代码中使用CFURLCreateStringByAddingPercentEscapes替换stringByAddingPercentEncodingWithAllowedCharacters

1 个答案:

答案 0 :(得分:-1)

使用下面的代码可能有帮助

CFStringRef escapedStr;
escapedStr = (__bridge CFStringRef)([str stringByAddingPercentEncodingWithAllowedCharacters:[kCFAllocatorDefault,originalString,leaveUnescaped,kCharsToForceEscape,kCFStringEncodingUTF8]]);// here str is your NSString