如何使用AFNetworking获取URL的内容?

时间:2016-01-08 18:40:07

标签: ios json swift afnetworking

Here是我需要下载到我的应用程序的内容。

这就是我要求的方式:

Description Resource    Path    Location    Type
missing or invalid dependency detected while loading class file 'ActorSystem.class'. Could not access term typesafe in package com, because it (or its dependencies) are missing. Check your build definition for missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.) A full rebuild may help if 'ActorSystem.class' was compiled against an incompatible version of com.    tst     Unknown Scala Problem

网址请求正确无误:GET("identifiers/pl-normal.json", parameters: nil, progress: nil, success: { sessionDataTask, response in }) { sessionDataTask, error in completionBlock(error) }

但调用GET Optional(http://www.taboo.blue-world.pl/api/identifiers/pl-normal.json)块,为什么?

1 个答案:

答案 0 :(得分:0)

如果无法正确解析网络请求的结果,则会在AFNetworking中调用错误块。换句话说,这是一个序列化错误。看起来你得到的内容没有正确格式化json。通过json linter运行您的服务器响应,并确保它是有效的,您应该全部设置。

如果这不起作用,请尝试在序列化程序中添加text / html作为可接受的内容类型,如此处所述 - Request failed: unacceptable content-type: text/html using AFNetworking 2.0