开发者

Double Quotes in NSURL request

开发者 https://www.devze.com 2023-02-05 23:30 出处:网络
Apache CouchDB requires the key to be enclosed by double quotes: \", however when escaped the resulting nsurl returns (null) when being logged to the console and the resulting response (null) as well,

Apache CouchDB requires the key to be enclosed by double quotes: ", however when escaped the resulting nsurl returns (null) when being logged to the console and the resulting response (null) as well, obviously.

Here's the code:

NSUR开发者_开发知识库L *url = [[NSURL alloc] initWithString:@"http://username:password@gcg.cloudant.com:5984/points/_design/user/_view/where?key=\"m0rph3v5\""];

I've also tried using %22 instead of the double quotes which didn't work either.

How can I succesfully add the double quotes in the request url?


Turns out it had to do with the stringWithFormat I used which tried to decypher %22 as a variable as well and thus screwing up the url.

Using a nsmutablestring and appending the key variable turned out to be working properly :)


Using %22 works for me. I get a valid NSURL object using this line of code:

NSURL *url = [[NSURL alloc] initWithString:@"http://username:password@gcg.cloudant.com:5984/points/_design/user/_view/where?key=%22m0rph3v5%22"];

The strange thing is that this works without escaping the @ sign.
IIRC it should also be escaped (%40).

0

精彩评论

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