我很难弄清楚如何准确地定义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的这个特性的原因。
发布于 2016-05-05 02:46:42
用Swift定义它,就像定义任何闭包一样。您可以为捕获的参数指定任何您想要的名称,也可以使用_给出任何名称,但是您需要有3个。
ImageDownloader().downloadImage(URLRequest: "http://httpbin.org/image/png", progress: { (bytesRead, totalBytesRead, totalExpectedBytesToRead) in
print("Read:\(bytesRead), Total Read: \(totalBytesRead), Expected: \(totalExpectedBytesToRead)")
})https://stackoverflow.com/questions/37040736
复制相似问题