清除圖片緩存

//清除緩存
        [self showAlertWithTitle:QHLocalizedString(@"確認清除緩存", nil) message:nil actions:@[QHLocalizedString(@"取消", nil), QHLocalizedString(@"確認", nil)] complete:^(NSInteger selIndex) {
            if (selIndex == 1) {
                //獲取緩存圖片的大小(字節)
//                NSUInteger bytesCache = [[SDImageCache sharedImageCache] getSize];
                //換算成 MB
//                float MBCache = bytesCache/1000/1000;
                //異步清除圖片緩存 (磁盤中的)
                dispatch_async(dispatch_get_global_queue(0, 0), ^{
                    [[SDImageCache sharedImageCache] clearDisk];
                    
                });
                
                __weak typeof(self) weakSelf = self;
                [[SDImageCache sharedImageCache] clearDiskOnCompletion:^{
                    __strong typeof(weakSelf) strongSelf = weakSelf;
                    [MBProgressHUD showMessag:QHLocalizedString(@"清除成功", nil) toView:strongSelf.view afterDelay:hiddenMBPTime];
                }];
                
            }
        }];
相關文章
相關標籤/搜索