Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/93.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 使用此方法更改NSURL字符串stringByAddingPercentEncodingWithAllowedCharacters_Ios_Objective C_Nsstring_Nsurl - Fatal编程技术网

Ios 使用此方法更改NSURL字符串stringByAddingPercentEncodingWithAllowedCharacters

Ios 使用此方法更改NSURL字符串stringByAddingPercentEncodingWithAllowedCharacters,ios,objective-c,nsstring,nsurl,Ios,Objective C,Nsstring,Nsurl,我有一根绳子 https://www.example.com/abc/Gesture-abc-mobile-app_%257E0177cae9d41f573e5f?source=rss 当我使用此方法在Url中将其转换为加载到UIWebView NSString *str = [[NSString stringWithFormat:@"%@", self.urlStr] stringByAddingPercentEncodingWithAllowedCharacters:NSCharacte

我有一根绳子

https://www.example.com/abc/Gesture-abc-mobile-app_%257E0177cae9d41f573e5f?source=rss
当我使用此方法在Url中将其转换为加载到
UIWebView

 NSString *str = [[NSString stringWithFormat:@"%@", self.urlStr] stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLQueryAllowedCharacterSet];
输出为:

 https://www.example.com/jobs/Gesture-initiated-mobile-app_%257E0177cae9d41f573e5f?source=rss%0A%20%20%20%20%20%20

告诉我为什么会发生这种情况…

字符串末尾有额外的字符-确切地说是回车符和空格:

NSString *urlStr = @"https://www.example.com/abc/Gesture-abc-mobile-app_%257E0177cae9d41f573e5f?source=rss\n     ";
结果

https://www.example.com/abc/Gesture-abc-mobile-app_%25257E0177cae9d41f573e5f?source=rss%0A%20%20%20%20%20

最后删除垃圾,你会得到想要的结果。

垃圾输入,垃圾输出?谢谢,我如何删除垃圾?({link=“\n”;title=“创建一个简单的移动应用程序Android-Upwork\n”},{link=“\n”title=“本机IOS&;Android应用程序项目-Upwork\n”},这甚至不是同一个字符串。
link=”https://www.example.com/jobs/Need-iOS-Android-apps-developer_%7E01f48b2d957183b068?source=rss\n”