Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift 如何使用AlamofireImage ProgressHandler_Swift_Alamofireimage - Fatal编程技术网

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)")
})