【发布时间】:2013-10-29 09:58:12
【问题描述】:
NSMutableString *string = [[NSMutableString alloc]initWithString:
@"http%3A%2F%2Fsupport24hour.com%2Fworkplace2%2Fbuttler%2Fimage.php%3Fwidth%3D534%26height%3D256%26image%3Duploads%2Fdeals%2FdealImage%2Fdeal_1383005121_IGA+Logo.JPG"];
[string replaceOccurrencesOfString:@"+" withString:@" " options:NSCaseInsensitiveSearch range:NSMakeRange(0, [string length])];
NSURL * url = [NSURL URLWithString:[string stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
【问题讨论】:
-
为其他网址工作
-
但不适用于上述网址
-
我在 iOS 7 上测试这个
-
将
http%3A%2F%2F更改为http:// -
为什么你使用一个已经百分比转义的字符串,你又百分比转义了?使用正常的,如果需要,操作字符串(用“”替换“+”)然后转义它。
标签: ios objective-c nsurl nsstringencoding