xcode 如何用格式替换字符串中的空格
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10898509/
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-15 00:30:31 来源:igfitidea点击:
How to replace spaces with + in string with format
提问by Pavel Kaljunen
Possible Duplicate:
How do i replace spaces with +'s in Xcode
可能的重复:
我如何在 Xcode 中用 + 替换空格
In this string I need to replace spaces:
在这个字符串中,我需要替换空格:
controller.body = [NSString stringWithFormat:@"http://maps.google.com/maps?q=%@@%@,%@", pinTitle.text, newlatLabel.text, newlogLabel.text];
回答by Rui Peres
Like:
喜欢:
NSString *finalString = [controller.body stringByReplacingOccurrencesOfString:@" " withString: @"+"];
controller.body = [NSString stringWithFormat:@"http://maps.google.com/maps?q=%@@%@,%@", pinTitle.text, newlatLabel.text, newlogLabel.text];
NSString *finalString = [controller.body stringByReplacingOccurrencesOfString:@" " withString: @"+"];
controller.body = finalString;
回答by Zaid Amir
Think you are looking for this:
认为你正在寻找这个:
NSString *finalString = [controller.body stringByReplacingOccurrencesOfString:@" " withString:@"+"];