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”