我如何在 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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 21:51:54  来源:igfitidea点击:

How do i replace spaces with +'s in Xcode

iphoneiosxcodesdkios-4.2

提问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:@"+"];