在9.0中不推荐使用stringByAddingPercentEscapesUsingEncoding.该怎么做? [英] stringByAddingPercentEscapesUsingEncoding was deprecated in 9.0 .How to do this?
本文介绍了在9.0中不推荐使用stringByAddingPercentEscapesUsingEncoding.该怎么做?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是一名初级开发人员,为此我得到了一个代码:
I'm a junior developer, and I got a code for this:
(NSString *)encodedStringFromObject:(id)object {
return [[object description] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
}
但是在9.0中必须使用stringByAddingPercentEncodingWithAllowedCharacters
.
But in 9.0 have to use stringByAddingPercentEncodingWithAllowedCharacters
.
如何传输此代码? 我需要帮助,谢谢!
How Could I transfer this code ? I need help, Thanks!
推荐答案
如果只想快速查看示例,请看以下代码:
If you want just fast example look at this code:
NSString * encodedString = [@"string to encode" stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]];
还要检查预定义字符集列表
如果要解释,请阅读文档或至少阅读以下主题:如何在Swift中编码URL
If you want explanation read the documents or at least this topic: How to encode a URL in Swift
这篇关于在9.0中不推荐使用stringByAddingPercentEscapesUsingEncoding.该怎么做?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文