それはまったく可能ですか?私は方法があることを知っています:
public func GET(URLString: String, parameters: AnyObject?, progress downloadProgress: ((NSProgress) -> Void)?, success: ((NSURLSessionDataTask, AnyObject?) -> Void)?, failure: ((NSURLSessionDataTask?, NSError) -> Void)?) -> NSURLSessionDataTask?
しかし、downloadProgress
ブロックはまったく呼び出されません。他の方法でこれを達成するにはどうすればよいですか?
これは、のサブクラスでメソッドを呼び出す方法ですAFHTTPSessionManager
。
GET("words", parameters: nil, progress: { progress in
print("---------- \(progress)") //not called
}, success: { sessionDataTask, response in
completionBlock(error) //this is called
}) { sessionDataTask, error in
completionBlock(error)
}
応答のヘッダー:
[サーバー: Apache、接続: Keep-Alive、Content-Type: application/json、日付: 金、2016 年 1 月 8 日 12:34:00 GMT、Content-Encoding: gzip、Keep-Alive: タイムアウト = 1、最大 = 100 、Content-Length: 5663、Vary: Accept-Encoding、User-Agent]