问题Xcode将字符“@”更改为“%40”

时间:2014-04-28 19:19:14

标签: json xcode web-services afnetworking

我在我的应用中使用了AFNetworking。

当我使用带有字段EMAIL的AFN时出现此错误:

Error: Error Domain=AFNetworkingErrorDomain Code=-1011 "Request failed: not found (404)" UserInfo=0x1096634a0 {NSLocalizedDescription=Request failed: not found (404), NSErrorFailingURLKey=http://mywebservice/vlemail?email=me%40domain.com, AFNetworkingOperationFailingURLResponseErrorKey=<NSHTTPURLResponse: 0x109558d10> { URL: http://mywebservice/vlemail?email=me%40domain.com } { status code: 404, headers {
    Connection = "keep-alive";
    "Content-Length" = 967;
    "Content-Type" = "text/html;charset=utf-8";
    Date = "Mon, 28 Apr 2014 19:01:43 GMT";
    Server = "nginx admin";
} }, NSUnderlyingError=0x1096756e0 "Request failed: unacceptable content-type: text/html"}

很奇怪,因为字段EMAIL是: NSLog(@&#34; txtEmail。:%@&#34;,_ txtEmail.text)= [2908:60b] txtEmail:me @ domain

但AFN的参数更改为:me%40domain

有人知道为什么吗?

非常感谢!

1 个答案:

答案 0 :(得分:0)

这可能是因为@符号编码为%40,类似于空格编码为%20。

http://en.wikipedia.org/wiki/Percent-encoding