Swift 如何使用AlamofireImage ProgressHandler
我很难弄清楚如何准确地定义Swift 如何使用AlamofireImage ProgressHandler,swift,alamofireimage,Swift,Alamofireimage,我很难弄清楚如何准确地定义ProgressHandler参数。typealias定义为public-typealias-ProgressHandler=(bytesSent:Int64,totalBytesSent:Int64,totalExpectedBytes:Int64)->Void 更多信息可在此处找到 不是复制品!引用的答案/问题是实现此功能的原因将其定义为Swift中的任何闭包。您可以根据需要为捕获的参数指定任何名称,也可以使用\uu不指定任何名称,但您需要3个名称。例如: Imag
ProgressHandler
参数。typealias
定义为public-typealias-ProgressHandler=(bytesSent:Int64,totalBytesSent:Int64,totalExpectedBytes:Int64)->Void
更多信息可在此处找到
不是复制品!引用的答案/问题是实现此功能的原因将其定义为Swift中的任何闭包。您可以根据需要为捕获的参数指定任何名称,也可以使用
\uu
不指定任何名称,但您需要3个名称。例如:
ImageDownloader().downloadImage(URLRequest: "http://httpbin.org/image/png", progress: { (bytesRead, totalBytesRead, totalExpectedBytesToRead) in
print("Read:\(bytesRead), Total Read: \(totalBytesRead), Expected: \(totalExpectedBytesToRead)")
})
什么意思?Xcode中的自动完成应该为您填写参数。你到底有什么问题?@JonShier我不知道如何定义参数,自动完成没有帮助。
ImageDownloader().downloadImage(URLRequest: "http://httpbin.org/image/png", progress: { (bytesRead, totalBytesRead, totalExpectedBytesToRead) in
print("Read:\(bytesRead), Total Read: \(totalBytesRead), Expected: \(totalExpectedBytesToRead)")
})