獲取本地緩存圖片的大小
ImageCache.default.calculateDiskStorageSize { (result) in
switch result {
case .success(let value):
let size = Double(value / 1024 / 1024)
valueString = String(format: "%.1fM", size)
case .failure(let error):
debugPrint(error.localizedDescription)
valueString = "獲取失敗"
}
cell.valueLbl.isHidden = false
cell.valueLbl.text = valueString
}
清除緩存
DispatchQueue.global().async {
ImageCache.default.clearDiskCache {
self.tableView.reloadRows(at: [IndexPath.init(row: 0, section: 2)], with: UITableView.RowAnimation.none)
DispatchQueue.main.async {
ZSProgressHUD.showMessage("清除成功")
}
}
}