不调用GET和AFNetworking 3.0的进度块

时间:2016-01-07 18:28:52

标签: ios swift afnetworking-3

我创建了AFHTTPSessionManager的子类:

class TBNetworkClient: AFHTTPSessionManager {
    func wordsWithCompletionBlock(completionBlock: TBErrorHandler) {

        queryType = .Words
        GET("words", parameters: nil, progress: { progress in

            print("----------") //this is not called at all, why?

            }, success: { sessionDataTask, response in

                completionBlock(nil) //success is called

            }) { sessionDataTask, error in

                completionBlock(error)
        }
    }
}

标记线根本没有被调用,为什么?

这是源代码中上面定义的方法:

public func GET(URLString: String, parameters: AnyObject?, progress downloadProgress: ((NSProgress) -> Void)?, success: ((NSURLSessionDataTask, AnyObject?) -> Void)?, failure: ((NSURLSessionDataTask?, NSError) -> Void)?) -> NSURLSessionDataTask?

还有一个注释:

  

@param progress更新下载进度时要执行的块对象。请注意,在会话队列上调用块,而不是主队列。

当我打印print((sessionDataTask.response as? NSHTTPURLResponse)?.allHeaderFields)

输出如下:

  

可选([服务器:Apache,连接:Keep-Alive,内容类型:text / html,日期:星期五,2016年1月8日08:58:18 GMT,内容编码:gzip,Keep-Alive:timeout = 1,max = 100,Content-Length:5663,Vary:Accept-Encoding,User-Agent])

0 个答案:

没有答案