开发者

Unknown escape sequence "\040" in Objective-C

I need to replace something like "abc%20def%20xyz" with "abc\ def\ xyz". I used this function that works fine.

string2 =[string2 stringByReplacingOccurrencesOfString:@"%20" withString:@"\ "];

However, I got warning saying

Unknown escape sequence "\040".

What开发者_如何转开发's wrong with this, and how can I remove this warning?


The backslash in the end string is escaping the space character, which isn't valid. To do what you want, you need to escape the backslash:

string2 =[string2 stringByReplacingOccurrencesOfString:@"%20" withString:@"\\ "];

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜