开发者

How to replace whitespaces by a plus "+" sign

hey 开发者_如何学运维all i want a code the replace whitespaces by a + sign in objective-c


In case you are asking this because you need to encode URLs, use this

NSString* escapedUrlString =
  [unescapedString stringByAddingPercentEscapesUsingEncoding: NSASCIIStringEncoding];

If you just need space to +, use

[str stringByReplacingOccurrencesOfString:@" " withString:@"+"];


return [thatString stringByReplacingOccurrencesOfString:@" " withString:@"+"];

If your real target is to escape URL component, use the -stringByAddingPercentEscapesUsingEncoding: method instead.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜