NSURL 请求中的双引号
Apache CouchDB 要求密钥用双引号括起来:“,但是,当转义时,生成的 nsurl 在记录到控制台时返回 (null),显然,生成的响应也返回 (null)。
这是代码:
NSURL *url = [[NSURL alloc] initWithString:@"http://username:[email protected]:5984/points/_design/user/_view/where?key=\"m0rph3v5\""];
我也尝试使用 %22 而不是双引号,但也不起作用。
如何在请求网址中成功添加双引号?
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:
NSURL *url = [[NSURL alloc] initWithString:@"http://username:[email protected]: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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
事实证明,这与我使用的 stringWithFormat 有关,它也试图将 %22 解密为变量,从而搞砸了 url。
使用 nsmutablestring 并附加关键变量结果可以正常工作:)
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 :)
使用 %22 对我有用。我使用这行代码获得了一个有效的 NSURL 对象:
奇怪的是,这无需转义 @ 符号即可工作。
IIRC 它也应该被转义 (%40)。
Using %22 works for me. I get a valid NSURL object using this line of code:
The strange thing is that this works without escaping the @ sign.
IIRC it should also be escaped (%40).