开发者

special character return nil in nsurl

开发者 https://www.devze.com 2023-01-11 00:04 出处:网络
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

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

精彩评论

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