Ios 如何将字符串中的空格替换为+格式
可能重复: 在此字符串中,我需要替换空格:Ios 如何将字符串中的空格替换为+格式,ios,xcode,string,replace,space,Ios,Xcode,String,Replace,Space,可能重复: 在此字符串中,我需要替换空格: controller.body = [NSString stringWithFormat:@"http://maps.google.com/maps?q=%@@%@,%@", pinTitle.text, newlatLabel.text, newlogLabel.text]; 比如: 我想你在找这个: NSString *finalString = [controller.body stringByReplacingOccurrencesOf
controller.body = [NSString stringWithFormat:@"http://maps.google.com/maps?q=%@@%@,%@", pinTitle.text, newlatLabel.text, newlogLabel.text];
比如:
我想你在找这个:
NSString *finalString = [controller.body stringByReplacingOccurrencesOfString:@" " withString:@"+"];
我把变量finalString放在哪里?你可以这样做:controller.body=finalString;如果你愿意,谢谢你!可能重复的工作:投票关闭
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;
NSString *finalString = [controller.body stringByReplacingOccurrencesOfString:@" " withString:@"+"];