首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用AlamofireImage ProgressHandler

如何使用AlamofireImage ProgressHandler
EN

Stack Overflow用户
提问于 2016-05-05 01:18:20
回答 1查看 585关注 0票数 1

我很难弄清楚如何准确地定义ProgressHandler参数。typealias被定义为public typealias ProgressHandler = (bytesSent: Int64, totalBytesSent: Int64, totalExpectedBytes: Int64) -> Void,更多信息可以在这里找到https://github.com/Alamofire/AlamofireImage/pull/91

代码语言:javascript
复制
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的这个特性的原因。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-05-05 02:46:42

用Swift定义它,就像定义任何闭包一样。您可以为捕获的参数指定任何您想要的名称,也可以使用_给出任何名称,但是您需要有3个。

代码语言:javascript
复制
ImageDownloader().downloadImage(URLRequest: "http://httpbin.org/image/png", progress: { (bytesRead, totalBytesRead, totalExpectedBytesToRead) in
    print("Read:\(bytesRead), Total Read: \(totalBytesRead), Expected: \(totalExpectedBytesToRead)")
})
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37040736

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档