我有代码,定期下载大量图像。代码看起来像这样
func batchProductPicsDownload() {
for product in products {
SDWebImageDownloader.shared().downloadImage(with: URL(string: APIMode.BackofficeRoot + product.img_url), options: [], progress: nil, completed: { (image, data, error, bool) in
if let image = image {
SDWebImageManager.shared().saveImage(toCache: image, for: URL(string: APIMode.BackofficeRoot + product.img_url))
}
})
}
}
问题是我有时会崩溃
如何解决?