我很难弄清楚我究竟能如何定义ProgressHandler
参数。 typealias
定义为public typealias ProgressHandler = (bytesSent: Int64, totalBytesSent: Int64, totalExpectedBytes: Int64) -> Void
更多信息可在此处找到https://github.com/Alamofire/AlamofireImage/pull/91
let URLRequest = NSURLRequest(URL: NSURL(string: "https://httpbin.org/image/jpeg")!)
ImageDownloader().downloadImages(URLRequests: [URLRequest], filter: nil,
progress: (init progress here), progressQueue: dispatch_get_main_queue(), completion: {
_ in
})
不是重复!引用的答案/问题是导致此功能实施的原因 https://stackoverflow.com/a/33503205/5222077
答案 0 :(得分:1)
像在Swift中的任何闭包一样定义它。您可以使用_
为捕获的参数提供所需的任何名称,但不需要使用ImageDownloader().downloadImage(URLRequest: "http://httpbin.org/image/png", progress: { (bytesRead, totalBytesRead, totalExpectedBytesToRead) in
print("Read:\(bytesRead), Total Read: \(totalBytesRead), Expected: \(totalExpectedBytesToRead)")
})
,但是您需要拥有3.例如:
echo $CLUSTER