1

Im working on a library for the LinkedIn api. In some cases i need to send a escaped url. Im using CFURLCreateStringByAddingPercentEscapes for this task and seems to work find for me.

Why this is not a valid URL?

NSURL *base = [NSURL URLWithString:@"https://api.linkedin.com"];
NSString *r = @"/v1/people/url={www.linkedin.com%2Fin%2Fbilby91}";
NSURL finalUrl = [NSURL URLWithString:r relativeToURL:base];

finalUrl is always null and i think is correctly escaped. The original url is www.linkedin.com/Fin/bilby91

Thanks

3 Answers 3

0

add this

NSString *r = [@"/v1/people/url={www.linkedin.com%2Fin%2Fbilby91}" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

0

The problem was that this characters '{' '}' need to be encoded even though they are not reserved. Some characters including the ones before are considered unsafe and can be misunderstood in the url so its better to always encode them.

-1
[NSString stringWithFormat:@"%@",[r stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

use this, this may help u

1
  • There is no point to the stringWithFormat: portion of this code Jan 10, 2014 at 10:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.