iosobjective-cnsurlnsstringencoding

NSURL URLWithString returns nil


I am stuck in a very obvious method of NSURL class URLWithString I am passing a string and while creating URL it returns nil, my string is perfect. When ever I uses same string in browser then it is working fine. I am using following method to convert NSString to NSURL:

NSURL *url = [NSURL URLWithString:urlString];
//urlString is my perfect string

I have also tried to encode my string first by using following

NSURL *url = [NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
// using this line my output string when I log url is "url%10%10%10%10%10%10..."

%10 becomes the suffix of my url with around 100+ repetition. If any one has idea what %10 is or what can be done to overcome this problem.

here is my urlString:
comment says too many character but it is obvious that there are not much characters


Solution

  • yes what was wrong in my string were many unidentified characters due to copying from internet site, if anyone of the reader facing this issue can copy and paste your string as see the count. And confirm. Thanks