tags:

views:

45

answers:

1

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 how to do this ?

Can anyone help me?

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

+3  A: 

You need to encode the special characters into URL codes :

NSString *encodedURLString = [urlString stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];

NSURL *URL = [NSURL URLWithString:encodedURLString];
deanWombourne
dragon
Have you tried passing that URL to the server? The server should translate the %25 back into a % for you. The fact that it says %25 at the end should be fine. At the very worst you will have to call the decode method on the server to turn %25 back to %.
deanWombourne