我如何在 Xcode 中用 + 替换空格
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7284380/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do i replace spaces with +'s in Xcode
提问by inVINCEable
I am building an app with a lot of urls being called from a MySQL server.
我正在构建一个应用程序,其中包含从 MySQL 服务器调用的大量 url。
What I need to do for my app is take the textfield text and send it (which i already know how to do) BUT i need to replace the spaces with + (pluses)
我需要为我的应用程序做的是获取文本字段文本并发送它(我已经知道该怎么做)但是我需要用 +(加号)替换空格
回答by aViNaSh
Try with the string method - (NSString *)stringByReplacingOccurrencesOfString:(NSString *)target withString:(NSString *)replacement;
尝试使用字符串方法 - (NSString *)stringByReplacingOccurrencesOfString:(NSString *)target withString:(NSString *)replacement;
str=[str stringByReplacingOccurrencesOfString:@" " withString:@"+"];

