开发者

special character return nil in nsurl

I have an nsstring like this

http://example.com/webservices/test?method=eventlist&title=Prog%

i want to change this nsstring to nsurl, but it returns nil in nsurl.I know it return nil because of percentage at the end, but i want to add percentage with every title to get an value.. So i dont know开发者_StackOverflow中文版 how to do this ?

Can anyone help me?

Thanks in advance............


You need to encode the special characters into URL codes :

NSString *encodedURLString = [urlString stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];

NSURL *URL = [NSURL URLWithString:encodedURLString];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜