dragon
dragon

Reputation: 317

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

Can anyone help me?

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

Upvotes: 1

Views: 739

Answers (1)

deanWombourne
deanWombourne

Reputation: 38475

You need to encode the special characters into URL codes :

NSString *encodedURLString = [urlString stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];

NSURL *URL = [NSURL URLWithString:encodedURLString];

Upvotes: 4

Related Questions